From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: master 3a284e5: Combine archive-int-to-mode and tar-grind-file-mode Date: Thu, 14 May 2020 15:51:05 -0400 Message-ID: References: <20200514164503.2999.1026@vcs0.savannah.gnu.org> <20200514164505.2F26320A29@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="53339"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Tino Calancha Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu May 14 21:52:30 2020 Return-path: Envelope-to: ged-emacs-devel@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 1jZJuA-000Dlt-C5 for ged-emacs-devel@m.gmane-mx.org; Thu, 14 May 2020 21:52:30 +0200 Original-Received: from localhost ([::1]:55812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZJu9-0005U5-Df for ged-emacs-devel@m.gmane-mx.org; Thu, 14 May 2020 15:52:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZJst-0004B2-QB for emacs-devel@gnu.org; Thu, 14 May 2020 15:51:11 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:6893) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZJsr-0005S8-Gn for emacs-devel@gnu.org; Thu, 14 May 2020 15:51:11 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 543FC4401A3; Thu, 14 May 2020 15:51:08 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 31F7B440193; Thu, 14 May 2020 15:51:06 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1589485866; bh=29p3L+C9suIz88qg254n5ZOv5BVrvptrVcxRmBRzRM4=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Q45ejQzhscqDmL9uESZCSynQNVtckCgziat+Ntvdrd+UNObxEDZ2dkFXuF+8xXhSH 9Uf9329HBVZ6RrLrvlk1xttY3bcQ+uFEJMWTnbKCpGhc2vPZEPa0aIhBIBK0snUGM9 E7IvOH/S3f5DGTh+yZLqv/YOc08EE4z3G4wunv9lN2jpFxhVhMlaNRq4N7Et0m2erx XzgIu1C3cKWVPGFB6bHrlEFdP0R42A55r80gHzaIAlrK4BkYli6K7jIWDVJtpSw7dd U8H6Ny2RYHlPtryjQpU8+TXPtAoTgcIA9dBa1ah2P1Ja8x7etpKSXC+JwMEdRURwTK EQ+xp9wm+AfAQ== Original-Received: from alfajor (unknown [216.154.3.202]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C3993120746; Thu, 14 May 2020 15:51:05 -0400 (EDT) In-Reply-To: <20200514164505.2F26320A29@vcs0.savannah.gnu.org> (Tino Calancha's message of "Thu, 14 May 2020 12:45:04 -0400 (EDT)") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 13:41:42 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:250283 Archived-At: > +(defun file-modes-number-to-symbolic (mode) > + (string > + (if (zerop (logand 8192 mode)) > + (if (zerop (logand 16384 mode)) ?- ?d) > + ?c) ; completeness BTW, I was looking at how to get rid of `tar-grind-file-mode` and along the way I saw that this first char is really representing the file type and there is no real standard for how a "modes" number can represent the file type. IOW the 8192/16484 above are fairly arbitrary (I suspect they correspond to what happens to be used in `.zip` files and probably won't match what's used in any other circumstance, e.g. they don't match what Git uses, IIUC). How 'bout the patch below? Stefan diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 6ce64fe24b3..82a79af8931 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -563,8 +563,13 @@ archive-l-e (aref str (- len i))))) result)) -(define-obsolete-function-alias 'archive-int-to-mode - 'file-modes-number-to-symbolic "28.1") +(defun archive-int-to-mode (mode) + ;; FIXME: Make this obsolete. For this, we will need to clarify + ;; where those 8192/16384 come from and what to do about them. + (file-modes-number-to-symbolic + mode (if (zerop (logand 8192 mode)) + (if (zerop (logand 16384 mode)) ?- ?d) + ?c))) (defun archive-calc-mode (oldmode newmode) "From the integer OLDMODE and the string NEWMODE calculate a new file mode. @@ -626,7 +631,8 @@ archive-get-descr (let ((item (aref archive-files no))) (if (and (archive--file-desc-p item) (let ((mode (archive--file-desc-mode item))) - (zerop (logand 16384 mode)))) + ;; FIXME: Why 16384? See comment in archive-int-to-mode. + (or (null mode) (zerop (logand 16384 mode))))) item (if (not noerror) (user-error "Entry is not a regular member of the archive")))) @@ -2119,7 +2125,6 @@ archive-7z-write-file-member ;; not the GNU nor the BSD extensions. As it turns out, this is sufficient ;; for .deb packages. -(autoload 'tar-grind-file-mode "tar-mode") (defconst archive-ar-file-header-re "\\(.\\{16\\}\\)\\([ 0-9]\\{12\\}\\)\\([ 0-9]\\{6\\}\\)\\([ 0-9]\\{6\\}\\)\\([ 0-7]\\{8\\}\\)\\([ 0-9]\\{10\\}\\)`\n") diff --git a/lisp/files.el b/lisp/files.el index dba704f7a4b..cfbe085f9c1 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -441,6 +441,7 @@ auto-save-visited-mode #'save-some-buffers :no-prompt (lambda () (and buffer-file-name + auto-save-visited-mode (not (and buffer-auto-save-file-name auto-save-visited-file-name)))))))) @@ -7552,11 +7553,14 @@ file-modes-rights-to-number op char-right))) num-rights)) -(defun file-modes-number-to-symbolic (mode) +(defun file-modes-number-to-symbolic (mode &optional filetype) + "Return a string describing a a file's MODE. +For instance, if MODE is #o700, then it produces `-rwx------'. +FILETYPE if provided should be a character denoting the type of file, +such as `?d' for a directory, or `?l' for a symbolic link and will replace +the leading `-' char." (string - (if (zerop (logand 8192 mode)) - (if (zerop (logand 16384 mode)) ?- ?d) - ?c) ; completeness + (or filetype ?-) (if (zerop (logand 256 mode)) ?- ?r) (if (zerop (logand 128 mode)) ?- ?w) (if (zerop (logand 64 mode)) diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el index 73978ffc4a7..75ffb5647e1 100644 --- a/lisp/tar-mode.el +++ b/lisp/tar-mode.el @@ -482,6 +482,7 @@ tar-grind-file-mode "Construct a `rw-r--r--' string indicating MODE. MODE should be an integer which is a file mode value. For instance, if mode is #o700, then it produces `rwx------'." + (declare (obsolete file-modes-number-to-symbolic "28.1")) (substring (file-modes-number-to-symbolic mode) 1)) (defun tar-header-block-summarize (tar-hblock &optional mod-p) @@ -497,25 +498,26 @@ tar-header-block-summarize ;; (ck (tar-header-checksum tar-hblock)) (type (tar-header-link-type tar-hblock)) (link-name (tar-header-link-name tar-hblock))) - (format "%c%c%s %7s/%-7s %7s%s %s%s" + (format "%c%s %7s/%-7s %7s%s %s%s" (if mod-p ?* ? ) - (cond ((or (eq type nil) (eq type 0)) ?-) - ((eq type 1) ?h) ; link - ((eq type 2) ?l) ; symlink - ((eq type 3) ?c) ; char special - ((eq type 4) ?b) ; block special - ((eq type 5) ?d) ; directory - ((eq type 6) ?p) ; FIFO/pipe - ((eq type 20) ?*) ; directory listing - ((eq type 28) ?L) ; next has longname - ((eq type 29) ?M) ; multivolume continuation - ((eq type 35) ?S) ; sparse - ((eq type 38) ?V) ; volume header - ((eq type 55) ?H) ; pax global extended header - ((eq type 72) ?X) ; pax extended header - (t ?\s) - ) - (tar-grind-file-mode mode) + (file-modes-number-to-symbolic + (tar-grind-file-mode mode) + (cond ((or (eq type nil) (eq type 0)) ?-) + ((eq type 1) ?h) ; link + ((eq type 2) ?l) ; symlink + ((eq type 3) ?c) ; char special + ((eq type 4) ?b) ; block special + ((eq type 5) ?d) ; directory + ((eq type 6) ?p) ; FIFO/pipe + ((eq type 20) ?*) ; directory listing + ((eq type 28) ?L) ; next has longname + ((eq type 29) ?M) ; multivolume continuation + ((eq type 35) ?S) ; sparse + ((eq type 38) ?V) ; volume header + ((eq type 55) ?H) ; pax global extended header + ((eq type 72) ?X) ; pax extended header + (t ?\s) + )) (if (= 0 (length uname)) uid uname) (if (= 0 (length gname)) gid gname) size