From: Gnus developers Date: Sun, 23 Mar 2014 23:14:52 +0000 (+0000) Subject: Merge from Gnus git master X-Git-Tag: emacs-25.0.90~2640^2~342 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7a31038fd91fec168aa6ff5d09ce9bfc819d25d5;p=emacs.git Merge from Gnus git master 2014-02-04 Lars Ingebrigtsen * calendar/parse-time.el (parse-time-iso8601-regexp) (parse-iso8601-time-string): Copied from `url-dav' so that we can use it more generally. 2014-02-01 Lars Ingebrigtsen * net/dns.el (network-interface-list): Define for XEmacs. 2014-01-31 Magnus Henoch * net/dns.el (dns-servers-up-to-date-p): New function to see whether the network interfaces changed. (dns-query): Use it to flush the data. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bd87881c9ba..b89cbc28461 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,19 @@ +2014-03-23 Lars Ingebrigtsen + + * calendar/parse-time.el (parse-time-iso8601-regexp) + (parse-iso8601-time-string): Copied from `url-dav' so that we can use + it more generally. + +2014-03-23 Lars Ingebrigtsen + + * net/dns.el (network-interface-list): Define for XEmacs. + +2014-03-23 Magnus Henoch + + * net/dns.el (dns-servers-up-to-date-p): New function to see whether + the network interfaces changed. + (dns-query): Use it to flush the data. + 2014-03-23 Juanma Barranquero * vc/vc.el (vc-rollback): Use set-buffer-modified-p. diff --git a/lisp/calendar/parse-time.el b/lisp/calendar/parse-time.el index 79569f2142c..6bfccec94c6 100644 --- a/lisp/calendar/parse-time.el +++ b/lisp/calendar/parse-time.el @@ -218,6 +218,68 @@ unknown are returned as nil." (rplaca (nthcdr (pop slots) time) new-val)))))))) time)) +(defconst parse-time-iso8601-regexp + (let* ((dash "-?") + (colon ":?") + (4digit "\\([0-9][0-9][0-9][0-9]\\)") + (2digit "\\([0-9][0-9]\\)") + (date-fullyear 4digit) + (date-month 2digit) + (date-mday 2digit) + (time-hour 2digit) + (time-minute 2digit) + (time-second 2digit) + (time-secfrac "\\(\\.[0-9]+\\)?") + (time-numoffset (concat "[-+]\\(" time-hour "\\):" time-minute)) + (time-offset (concat "Z" time-numoffset)) + (partial-time (concat time-hour colon time-minute colon time-second + time-secfrac)) + (full-date (concat date-fullyear dash date-month dash date-mday)) + (full-time (concat partial-time time-offset)) + (date-time (concat full-date "T" full-time))) + (list (concat "^" full-date) + (concat "T" partial-time) + (concat "Z" time-numoffset))) + "List of regular expressions matching ISO 8601 dates. +1st regular expression matches the date. +2nd regular expression matches the time. +3rd regular expression matches the (optional) timezone specification.") + +(defun parse-iso8601-time-string (date-string) + (let* ((date-re (nth 0 parse-time-iso8601-regexp)) + (time-re (nth 1 parse-time-iso8601-regexp)) + (tz-re (nth 2 parse-time-iso8601-regexp)) + re-start + time seconds minute hour fractional-seconds + day month year day-of-week dst tz) + ;; We need to populate 'time' with + ;; (SEC MIN HOUR DAY MON YEAR DOW DST TZ) + + ;; Nobody else handles iso8601 correctly, let's do it ourselves. + (when (string-match date-re date-string re-start) + (setq year (string-to-number (match-string 1 date-string)) + month (string-to-number (match-string 2 date-string)) + day (string-to-number (match-string 3 date-string)) + re-start (match-end 0)) + (when (string-match time-re date-string re-start) + (setq hour (string-to-number (match-string 1 date-string)) + minute (string-to-number (match-string 2 date-string)) + seconds (string-to-number (match-string 3 date-string)) + fractional-seconds (string-to-number (or + (match-string 4 date-string) + "0")) + re-start (match-end 0)) + (when (string-match tz-re date-string re-start) + (setq tz (match-string 1 date-string))) + (setq time (list seconds minute hour day month year day-of-week dst tz)))) + + ;; Fall back to having Gnus do fancy things for us. + (when (not time) + (setq time (parse-time-string date-string))) + + (and time + (apply 'encode-time time)))) + (provide 'parse-time) ;;; parse-time.el ends here diff --git a/lisp/mail/hashcash.el b/lisp/mail/hashcash.el index 2224884eede..fb8dfba8554 100644 --- a/lisp/mail/hashcash.el +++ b/lisp/mail/hashcash.el @@ -47,10 +47,6 @@ ;;; Code: -;; For Emacs <22.2 and XEmacs. -(eval-and-compile - (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) - (eval-when-compile (require 'cl)) ; for case (defgroup hashcash nil diff --git a/lisp/net/dns.el b/lisp/net/dns.el index e52ead1fb72..ea1c805c6b9 100644 --- a/lisp/net/dns.el +++ b/lisp/net/dns.el @@ -31,6 +31,12 @@ "List of DNS servers to query. If nil, /etc/resolv.conf and nslookup will be consulted.") +(defvar dns-servers-valid-for-interfaces nil + "The return value of `network-interface-list' when `dns-servers' was set. +If the set of network interfaces and/or their IP addresses +change, then presumably the list of DNS servers needs to be +updated. Set this variable to t to disable the check.") + ;;; Internal code: (defvar dns-query-types @@ -297,6 +303,17 @@ If TCP-P, the first two bytes of the package with be the length field." (t string))) (goto-char point)))) +(declare-function network-interface-list "process.c") + +(defun dns-servers-up-to-date-p () + "Return false if we need to recheck the list of DNS servers." + (and dns-servers + (or (eq dns-servers-valid-for-interfaces t) + ;; `network-interface-list' was introduced in Emacs 22.1. + (not (fboundp 'network-interface-list)) + (equal dns-servers-valid-for-interfaces + (network-interface-list))))) + (defun dns-set-servers () "Set `dns-servers' to a list of DNS servers or nil if none are found. Parses \"/etc/resolv.conf\" or calls \"nslookup\"." @@ -314,7 +331,9 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"." (goto-char (point-min)) (re-search-forward "^Address:[ \t]*\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" nil t) - (setq dns-servers (list (match-string 1))))))) + (setq dns-servers (list (match-string 1)))))) + (when (fboundp 'network-interface-list) + (setq dns-servers-valid-for-interfaces (network-interface-list)))) (defun dns-read-txt (string) (if (> (length string) 1) @@ -378,7 +397,7 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"." If FULLP, return the entire record returned. If REVERSEP, look up an IP address." (setq type (or type 'A)) - (unless dns-servers + (unless (dns-servers-up-to-date-p) (dns-set-servers)) (when reversep