mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-04 11:00:45 -08:00
Prefer ‘time-equal-p’ to ‘equal’ on timestamps
This is more robust since timestamps can have multiple forms. * lisp/auth-source.el (auth-source-netrc-parse): * lisp/bookmark.el (bookmark--watch-file-already-queried-p) (bookmark-maybe-load-default-file): * lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p): * lisp/dired.el (dired-directory-changed-p): * lisp/files.el (dir-locals-find-file): * lisp/gnus/gnus-util.el (gnus-cache-file-contents): * lisp/gnus/nneething.el (nneething-create-mapping): * lisp/gnus/nnfolder.el (nnfolder-read-folder): * lisp/gnus/nnmaildir.el (nnmaildir--update-nov) (nnmaildir--scan, nnmaildir-request-scan) (nnmaildir-request-update-info): * lisp/gnus/nnmh.el (nnmh-update-gnus-unreads): * lisp/gnus/spam-stat.el (spam-stat-load): * lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases): * lisp/mail/sendmail.el (sendmail-sync-aliases): * lisp/net/netrc.el (netrc-parse): * lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file): * lisp/play/cookie1.el (cookie-snarf): * lisp/vc/vc-cvs.el (vc-cvs-state-heuristic): * lisp/vc/vc-hg.el (vc-hg--ignore-patterns-valid-p) (vc-hg--cached-dirstate-search): * lisp/vc/vc-hooks.el (vc-after-save): Prefer ‘time-equal-p’ to ‘equal’ when comparing timestamps for equality.
This commit is contained in:
parent
a51863f73d
commit
2cd204d8bb
19 changed files with 36 additions and 27 deletions
|
|
@ -957,7 +957,8 @@ Note that the MAX parameter is used so we can exit the parse early."
|
|||
result)
|
||||
|
||||
(if (and (functionp cached-secrets)
|
||||
(equal cached-mtime
|
||||
(time-equal-p
|
||||
cached-mtime
|
||||
(file-attribute-modification-time
|
||||
(file-attributes file))))
|
||||
(progn
|
||||
|
|
|
|||
|
|
@ -1172,7 +1172,7 @@ it to the name of the bookmark currently being set, advancing
|
|||
(defun bookmark--watch-file-already-queried-p (new-mtime)
|
||||
;; Don't ask repeatedly if user already said "no" to reloading a
|
||||
;; file with this mtime:
|
||||
(prog1 (equal new-mtime bookmark--watch-already-asked-mtime)
|
||||
(prog1 (time-equal-p new-mtime bookmark--watch-already-asked-mtime)
|
||||
(setq bookmark--watch-already-asked-mtime new-mtime)))
|
||||
|
||||
(defun bookmark-maybe-load-default-file ()
|
||||
|
|
@ -1185,7 +1185,7 @@ it to the name of the bookmark currently being set, advancing
|
|||
(let ((new-mtime (nth 5 (file-attributes
|
||||
(car bookmark-bookmarks-timestamp))))
|
||||
(old-mtime (cdr bookmark-bookmarks-timestamp)))
|
||||
(and (not (equal new-mtime old-mtime))
|
||||
(and (not (time-equal-p new-mtime old-mtime))
|
||||
(not (bookmark--watch-file-already-queried-p new-mtime))
|
||||
(or (eq 'silent bookmark-watch-bookmark-file)
|
||||
(yes-or-no-p
|
||||
|
|
|
|||
|
|
@ -609,7 +609,7 @@ The file associated with OBJ does not need to be in a buffer."
|
|||
(or (not (slot-boundp obj 'tags))
|
||||
;; (not (oref obj tags)) --> not needed anymore?
|
||||
(/= (or (oref obj fsize) 0) actualsize)
|
||||
(not (equal (oref obj lastmodtime) actualmod))
|
||||
(not (time-equal-p (oref obj lastmodtime) actualmod))
|
||||
)
|
||||
))))
|
||||
|
||||
|
|
|
|||
|
|
@ -1140,7 +1140,8 @@ If DIRNAME is already in a Dired buffer, that buffer is used without refresh."
|
|||
(modtime (visited-file-modtime)))
|
||||
(or (eq modtime 0)
|
||||
(not (eq (file-attribute-type attributes) t))
|
||||
(equal (file-attribute-modification-time attributes) modtime)))))
|
||||
(time-equal-p (file-attribute-modification-time attributes)
|
||||
modtime)))))
|
||||
|
||||
(defvar auto-revert-remote-files)
|
||||
|
||||
|
|
|
|||
|
|
@ -4446,7 +4446,8 @@ This function returns either:
|
|||
;; The entry MTIME should match the most recent
|
||||
;; MTIME among matching files.
|
||||
(and cached-files
|
||||
(equal (nth 2 dir-elt)
|
||||
(time-equal-p
|
||||
(nth 2 dir-elt)
|
||||
(let ((latest 0))
|
||||
(dolist (f cached-files latest)
|
||||
(let ((f-time
|
||||
|
|
|
|||
|
|
@ -1254,7 +1254,7 @@ SPEC is a predicate specifier that contains stuff like `or', `and',
|
|||
contents value)
|
||||
(if (or (null (setq value (symbol-value variable)))
|
||||
(not (equal (car value) file))
|
||||
(not (equal (nth 1 value) time)))
|
||||
(not (time-equal-p (nth 1 value) time)))
|
||||
(progn
|
||||
(setq contents (funcall function file))
|
||||
(set variable (list file time contents))
|
||||
|
|
|
|||
|
|
@ -245,7 +245,8 @@ included.")
|
|||
(while map
|
||||
(if (and (member (cadr (car map)) files)
|
||||
;; We also remove files that have changed mod times.
|
||||
(equal (file-attribute-modification-time (file-attributes
|
||||
(time-equal-p
|
||||
(file-attribute-modification-time (file-attributes
|
||||
(nneething-file-name (cadr (car map)))))
|
||||
(cadr (cdar map))))
|
||||
(progn
|
||||
|
|
|
|||
|
|
@ -860,7 +860,8 @@ deleted. Point is left where the deleted region was."
|
|||
(nnheader-find-file-noselect file t)))))
|
||||
(mm-enable-multibyte) ;; Use multibyte buffer for future copying.
|
||||
(buffer-disable-undo)
|
||||
(if (equal (cadr (assoc group nnfolder-scantime-alist))
|
||||
(if (time-equal-p
|
||||
(cadr (assoc group nnfolder-scantime-alist))
|
||||
(file-attribute-modification-time (file-attributes file)))
|
||||
;; This looks up-to-date, so we don't do any scanning.
|
||||
(if (file-exists-p file)
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ This variable is set by `nnmaildir-request-article'.")
|
|||
;; usable: if the message has been edited or if nnmail-extra-headers
|
||||
;; has been augmented since this data was parsed from the message,
|
||||
;; then we have to reparse. Otherwise it's up-to-date.
|
||||
(when (and nov (equal mtime (nnmaildir--nov-get-mtime nov)))
|
||||
(when (and nov (time-equal-p mtime (nnmaildir--nov-get-mtime nov)))
|
||||
;; The timestamp matches. Now check nnmail-extra-headers.
|
||||
(setq old-extra (nnmaildir--nov-get-extra nov))
|
||||
(when (equal nnmaildir--extra old-extra) ;; common case
|
||||
|
|
@ -799,7 +799,7 @@ This variable is set by `nnmaildir-request-article'.")
|
|||
isnew
|
||||
(throw 'return t))
|
||||
(setq nattr (file-attribute-modification-time nattr))
|
||||
(if (equal nattr (nnmaildir--grp-new group))
|
||||
(if (time-equal-p nattr (nnmaildir--grp-new group))
|
||||
(setq nattr nil))
|
||||
(if read-only (setq dir (and (or isnew nattr) ndir))
|
||||
(when (or isnew nattr)
|
||||
|
|
@ -811,7 +811,7 @@ This variable is set by `nnmaildir-request-article'.")
|
|||
(rename-file x (concat cdir (nnmaildir--ensure-suffix file)))))
|
||||
(setf (nnmaildir--grp-new group) nattr))
|
||||
(setq cattr (file-attribute-modification-time (file-attributes cdir)))
|
||||
(if (equal cattr (nnmaildir--grp-cur group))
|
||||
(if (time-equal-p cattr (nnmaildir--grp-cur group))
|
||||
(setq cattr nil))
|
||||
(setq dir (and (or isnew cattr) cdir)))
|
||||
(unless dir (throw 'return t))
|
||||
|
|
@ -899,7 +899,7 @@ This variable is set by `nnmaildir-request-article'.")
|
|||
(remhash scan-group groups))
|
||||
(setq x (file-attribute-modification-time (file-attributes srv-dir))
|
||||
scan-group (null scan-group))
|
||||
(if (equal x (nnmaildir--srv-mtime nnmaildir--cur-server))
|
||||
(if (time-equal-p x (nnmaildir--srv-mtime nnmaildir--cur-server))
|
||||
(when scan-group
|
||||
(maphash (lambda (group-name _group)
|
||||
(nnmaildir--scan group-name t groups
|
||||
|
|
@ -1049,7 +1049,7 @@ This variable is set by `nnmaildir-request-article'.")
|
|||
(t
|
||||
markdir-mtime))))
|
||||
(puthash mark mtime new-mmth)
|
||||
(when (equal mtime (gethash mark old-mmth))
|
||||
(when (time-equal-p mtime (gethash mark old-mmth))
|
||||
(setq ranges (assq mark old-marks))
|
||||
(if ranges (setq ranges (cdr ranges)))
|
||||
(throw 'got-ranges nil))
|
||||
|
|
|
|||
|
|
@ -539,7 +539,7 @@ as unread by Gnus.")
|
|||
(let ((arts articles)
|
||||
art)
|
||||
(while (setq art (pop arts))
|
||||
(when (not (equal
|
||||
(when (not (time-equal-p
|
||||
(file-attribute-modification-time
|
||||
(file-attributes (concat dir (int-to-string (car art)))))
|
||||
(cdr art)))
|
||||
|
|
|
|||
|
|
@ -422,7 +422,8 @@ spam-stat (spam-stat-to-hash-table '(" spam-stat-ngood spam-stat-nbad))
|
|||
(cond (spam-stat-dirty (message "Spam stat not loaded: spam-stat-dirty t"))
|
||||
((or (not (boundp 'spam-stat-last-saved-at))
|
||||
(null spam-stat-last-saved-at)
|
||||
(not (equal spam-stat-last-saved-at
|
||||
(not (time-equal-p
|
||||
spam-stat-last-saved-at
|
||||
(file-attribute-modification-time
|
||||
(file-attributes spam-stat-file)))))
|
||||
(progn
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ no aliases, which is represented by this being a table with no entries.)")
|
|||
(if (file-exists-p mail-personal-alias-file)
|
||||
(let ((modtime (file-attribute-modification-time
|
||||
(file-attributes mail-personal-alias-file))))
|
||||
(if (not (equal mail-abbrev-modtime modtime))
|
||||
(if (not (time-equal-p mail-abbrev-modtime modtime))
|
||||
(progn
|
||||
(setq mail-abbrev-modtime modtime)
|
||||
(build-mail-abbrevs)))))))
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ This also saves the value of `send-mail-function' via Customize."
|
|||
(when mail-personal-alias-file
|
||||
(let ((modtime (file-attribute-modification-time
|
||||
(file-attributes mail-personal-alias-file))))
|
||||
(or (equal mail-alias-modtime modtime)
|
||||
(or (time-equal-p mail-alias-modtime modtime)
|
||||
(setq mail-alias-modtime modtime
|
||||
mail-aliases t)))))
|
||||
|
||||
|
|
|
|||
|
|
@ -63,8 +63,9 @@
|
|||
"port"))
|
||||
alist elem result pair)
|
||||
(if (and netrc-cache
|
||||
(equal (car netrc-cache) (file-attribute-modification-time
|
||||
(file-attributes file))))
|
||||
(time-equal-p (car netrc-cache)
|
||||
(file-attribute-modification-time
|
||||
(file-attributes file))))
|
||||
(insert (base64-decode-string (rot13-string (cdr netrc-cache))))
|
||||
(insert-file-contents file)
|
||||
(when (string-match "\\.gpg\\'" file)
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ or nil."
|
|||
(setq rng-schema-locating-file-alist
|
||||
(delq cached rng-schema-locating-file-alist)))
|
||||
nil)
|
||||
((and cached (equal (nth 1 cached) mtime))
|
||||
((and cached (time-equal-p (nth 1 cached) mtime))
|
||||
(nth 2 cached))
|
||||
(t
|
||||
(setq parsed (rng-parse-schema-locating-file file))
|
||||
|
|
|
|||
|
|
@ -123,7 +123,8 @@ Emit STARTMSG and ENDMSG before and after. Cache the result; second
|
|||
and subsequent calls on the same file won't go to disk."
|
||||
(setq phrase-file (cookie-check-file phrase-file))
|
||||
(let ((sym (intern-soft phrase-file cookie-cache)))
|
||||
(and sym (not (equal (symbol-function sym)
|
||||
(and sym (not (time-equal-p
|
||||
(symbol-function sym)
|
||||
(file-attribute-modification-time
|
||||
(file-attributes phrase-file))))
|
||||
(yes-or-no-p (concat phrase-file
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ See also variable `vc-cvs-sticky-date-format-string'."
|
|||
(let ((checkout-time (vc-file-getprop file 'vc-checkout-time))
|
||||
(lastmod (file-attribute-modification-time (file-attributes file))))
|
||||
(cond
|
||||
((equal checkout-time lastmod) 'up-to-date)
|
||||
((time-equal-p checkout-time lastmod) 'up-to-date)
|
||||
((string= (vc-working-revision file) "0") 'added)
|
||||
((null checkout-time) 'unregistered)
|
||||
(t 'edited))))
|
||||
|
|
|
|||
|
|
@ -966,7 +966,7 @@ REPO must be the directory name of an hg repository."
|
|||
(attr (file-attributes (nth 0 fs)))
|
||||
(current-mtime (file-attribute-modification-time attr))
|
||||
(current-size (file-attribute-size attr)))
|
||||
(unless (and (equal saved-mtime current-mtime)
|
||||
(unless (and (time-equal-p saved-mtime current-mtime)
|
||||
(equal saved-size current-size))
|
||||
(setf valid nil))))
|
||||
valid))
|
||||
|
|
@ -1037,7 +1037,7 @@ Avoids the need to repeatedly scan dirstate on repeated calls to
|
|||
)
|
||||
(if (and cache
|
||||
(equal dirstate (pop cache))
|
||||
(equal mtime (pop cache))
|
||||
(time-equal-p mtime (pop cache))
|
||||
(equal size (pop cache))
|
||||
(equal ascii-fname (pop cache)))
|
||||
(pop cache)
|
||||
|
|
|
|||
|
|
@ -631,9 +631,10 @@ Before doing that, check if there are any old backups and get rid of them."
|
|||
(cond
|
||||
((null backend))
|
||||
((eq (vc-checkout-model backend (list file)) 'implicit)
|
||||
;; If the file was saved in the same second in which it was
|
||||
;; If the file was saved at the same time that it was
|
||||
;; checked out, clear the checkout-time to avoid confusion.
|
||||
(if (equal (vc-file-getprop file 'vc-checkout-time)
|
||||
(if (time-equal-p
|
||||
(vc-file-getprop file 'vc-checkout-time)
|
||||
(file-attribute-modification-time (file-attributes file)))
|
||||
(vc-file-setprop file 'vc-checkout-time nil))
|
||||
(if (vc-state-refresh file backend)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue