emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "M-x locate" regression


From: Luc Teirlinck
Subject: Re: "M-x locate" regression
Date: Wed, 9 Nov 2005 23:02:00 -0600 (CST)

Nick Roberts (talking about find-lisp-find-dired) wrote:

   The GID is listed as a number, which seems a bit strange.

There is worse.  The UID is also a number, except for the user who is
running Emacs.  This is a misfeature.  There is still worse, if you
run Emacs with the -u option.  For instance if I su to root but run
Emacs with `-u teirllm', then find-lisp-find-dired falsely lists all
files owned by root as owned by teirllm.  This is an outright bug.

The patch below fixes the UID-bug, as well as the UID-misfeature.  It
also updates a partially obsolete comment.  I will install the patch
if there are no objections.

In as far as the GID misfeature is concerned, if I understand
correctly, find-lisp.el, like ls-lisp.el, tries to get the directory
listing completely from Lisp, without directly or indirectly (through
dired) using the ls program.  Given that, I do not know how to convert
the GID to a string.  If I understand correctly, then on some
operating systems, ls-lisp.el uses numeric UID and GID too.  So if it
would now be easy convert the GID to the group name from Lisp, then
ls-lisp should probably be changed too.  (See the comment on line 521
of ls-lisp.el.)

My patch _does_ take care of the case where file-attributes actually
lists the GID as a string (the current find-lisp code throws an error
in that case).  A comment in ls-lisp says that this case _can_ occur.

Here is my patch:

===File ~/find-lisp-diff====================================
*** find-lisp.el        09 Nov 2005 17:05:07 -0600      1.10
--- find-lisp.el        09 Nov 2005 22:48:11 -0600      
***************
*** 3,9 ****
  ;; Author: Peter Breton
  ;; Created: Fri Mar 26 1999
  ;; Keywords: unix
! ;; Time-stamp: <2005-11-09 22:55:41 teirllm>
  
  ;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
  ;;   2005 Free Software Foundation, Inc.
--- 3,9 ----
  ;; Author: Peter Breton
  ;; Created: Fri Mar 26 1999
  ;; Keywords: unix
! ;; Time-stamp: <2005-11-09 22:48:11 teirllm>
  
  ;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
  ;;   2005 Free Software Foundation, Inc.
***************
*** 309,326 ****
            (if (memq ?s switches)      ; size in K
                (format "%4d " (1+ (/ (nth 7 file-attr) 1024))))
            (nth 8 file-attr)           ; permission bits
!           ;; numeric uid/gid are more confusing than helpful
!           ;; Emacs should be able to make strings of them.
!           ;; user-login-name and user-full-name could take an
!           ;; optional arg.
            (format " %3d %-8s %-8s %8d "
                    (nth 1 file-attr)   ; no. of links
!                   (if (= (user-uid) (nth 2 file-attr))
!                       (user-login-name)
!                     (int-to-string (nth 2 file-attr)))        ; uid
                    (if (eq system-type 'ms-dos)
                        "root"          ; everything is root on MSDOS.
!                     (int-to-string (nth 3 file-attr)))        ; gid
                    (nth 7 file-attr)   ; size in bytes
                    )
            (find-lisp-format-time file-attr switches now)
--- 309,327 ----
            (if (memq ?s switches)      ; size in K
                (format "%4d " (1+ (/ (nth 7 file-attr) 1024))))
            (nth 8 file-attr)           ; permission bits
!           ;; numeric gid is more confusing than helpful.
!           ;; Emacs should be able to convert it into a string.
            (format " %3d %-8s %-8s %8d "
                    (nth 1 file-attr)   ; no. of links
!                   (if (integerp (nth 2 file-attr))
!                       (or (user-login-name (nth 2 file-attr))
!                           (int-to-string (nth 2 file-attr)))
!                     (nth 2 file-attr)) ; uid
                    (if (eq system-type 'ms-dos)
                        "root"          ; everything is root on MSDOS.
!                     (if (integerp (nth 3 file-attr))
!                         (int-to-string (nth 3 file-attr))
!                       (nth 3 file-attr))) ; gid
                    (nth 7 file-attr)   ; size in bytes
                    )
            (find-lisp-format-time file-attr switches now)
============================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]