commit c48e539226a062d01b8d5534644fae959506a743 (HEAD, refs/remotes/origin/master) Author: Tino Calancha Date: Thu May 18 14:47:06 2017 +0900 Use the expression angle units while simplifying it Don't use the angle mode, use the angle units included in the expression instead (Bug#23889). * lisp/calc/calc-alg.el (calc-input-angle-units): New defun. (math-simplify): Use it. * lisp/calc/calc-forms.el (math-to-hms, math-from-hms): Don't use calc-angle-mode if math-simplifying-units is non-nil. * lisp/calc/calc-math.el (calcFunc-nroot, math-from-radians) (math-to-radians-2, math-from-radians-2): Don't convert angle to radians if math-simplifying-units is non-nil. * test/lisp/calc/calc-tests.el (test-calc-23889): Add test. diff --git a/lisp/calc/calc-alg.el b/lisp/calc/calc-alg.el index 4e63d238c7..9db901a975 100644 --- a/lisp/calc/calc-alg.el +++ b/lisp/calc/calc-alg.el @@ -355,10 +355,19 @@ ;; math-simplify-step, which is called by math-simplify. (defvar math-top-only) +(defun calc-input-angle-units (input) + (cond ((math-expr-contains input '(var deg var-deg)) 'deg) + ((math-expr-contains input '(var rad var-rad)) 'rad) + ((math-expr-contains input '(var hms var-hms)) 'hms) + (t nil))) + ;; math-normalize-error is declared in calc.el. (defvar math-normalize-error) (defun math-simplify (top-expr) (let ((math-simplifying t) + (calc-angle-mode (if (calc-input-angle-units top-expr) + 'rad + calc-angle-mode)) (math-top-only (consp calc-simplify-mode)) (simp-rules (append (and (calc-has-rules 'var-AlgSimpRules) '((var AlgSimpRules var-AlgSimpRules))) diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el index abf76cf07e..6aa421ec20 100644 --- a/lisp/calc/calc-forms.el +++ b/lisp/calc/calc-forms.el @@ -317,7 +317,9 @@ (list 'calcFunc-hms a)) ((math-negp a) (math-neg (math-to-hms (math-neg a) ang))) - ((eq (or ang calc-angle-mode) 'rad) + ((eq (or ang + (and (not math-simplifying-units) calc-angle-mode)) + 'rad) (math-to-hms (math-div a (math-pi-over-180)) 'deg)) ((memq (car-safe a) '(cplx polar)) a) (t @@ -354,12 +356,16 @@ (if (eq (car-safe a) 'sdev) (math-make-sdev (math-from-hms (nth 1 a) ang) (math-from-hms (nth 2 a) ang)) - (if (eq (or ang calc-angle-mode) 'rad) + (if (eq (or ang + (and (not math-simplifying-units) calc-angle-mode)) + 'rad) (list 'calcFunc-rad a) (list 'calcFunc-deg a))))) ((math-negp a) (math-neg (math-from-hms (math-neg a) ang))) - ((eq (or ang calc-angle-mode) 'rad) + ((eq (or ang + (and (not math-simplifying-units) calc-angle-mode)) + 'rad) (math-mul (math-from-hms a 'deg) (math-pi-over-180))) (t (math-add (math-div (math-add (math-div (nth 3 a) diff --git a/lisp/calc/calc-math.el b/lisp/calc/calc-math.el index faa318d45d..2590761d53 100644 --- a/lisp/calc/calc-math.el +++ b/lisp/calc/calc-math.el @@ -763,12 +763,14 @@ If this can't be done, return NIL." (defun math-to-radians (a) ; [N N] (cond ((eq (car-safe a) 'hms) (math-from-hms a 'rad)) - ((memq calc-angle-mode '(deg hms)) + ((and (not math-simplifying-units) + (memq calc-angle-mode '(deg hms))) (math-mul a (math-pi-over-180))) (t a))) (defun math-from-radians (a) ; [N N] - (cond ((eq calc-angle-mode 'deg) + (cond ((and (not math-simplifying-units) + (eq calc-angle-mode 'deg)) (if (math-constp a) (math-div a (math-pi-over-180)) (list 'calcFunc-deg a))) @@ -779,14 +781,16 @@ If this can't be done, return NIL." (defun math-to-radians-2 (a &optional force-symbolic) ; [N N] (cond ((eq (car-safe a) 'hms) (math-from-hms a 'rad)) - ((memq calc-angle-mode '(deg hms)) + ((and (not math-simplifying-units) + (memq calc-angle-mode '(deg hms))) (if (or calc-symbolic-mode force-symbolic) (math-div (math-mul a '(var pi var-pi)) 180) (math-mul a (math-pi-over-180)))) (t a))) (defun math-from-radians-2 (a &optional force-symbolic) ; [N N] - (cond ((memq calc-angle-mode '(deg hms)) + (cond ((and (not math-simplifying-units) + (memq calc-angle-mode '(deg hms))) (if (or calc-symbolic-mode force-symbolic) (math-div (math-mul 180 a) '(var pi var-pi)) (math-div a (math-pi-over-180)))) diff --git a/test/lisp/calc/calc-tests.el b/test/lisp/calc/calc-tests.el index 8f56d48d01..68567dcc21 100644 --- a/test/lisp/calc/calc-tests.el +++ b/test/lisp/calc/calc-tests.el @@ -86,6 +86,50 @@ An existing calc stack is reused, otherwise a new one is created." (math-read-expr "1m") "cm") '(* -100 (var cm var-cm))))) +(ert-deftest test-calc-23889 () + "Test for http://debbugs.gnu.org/23889 and 25652." + (dolist (mode '(deg rad)) + (let ((calc-angle-mode mode)) + ;; If user inputs angle units, then should ignore `calc-angle-mode'. + (should (string= "5253" + (substring + (number-to-string + (nth 1 + (math-simplify-units + '(calcFunc-cos (* 45 (var rad var-rad)))))) + 0 4))) + (should (string= "7071" + (substring + (number-to-string + (nth 1 + (math-simplify-units + '(calcFunc-cos (* 45 (var deg var-deg)))))) + 0 4))) + (should (string= "8939" + (substring + (number-to-string + (nth 1 + (math-simplify-units + '(+ (calcFunc-sin (* 90 (var rad var-rad))) + (calcFunc-cos (* 90 (var deg var-deg))))))) + 0 4))) + (should (string= "5519" + (substring + (number-to-string + (nth 1 + (math-simplify-units + '(+ (calcFunc-sin (* 90 (var deg var-deg))) + (calcFunc-cos (* 90 (var rad var-rad))))))) + 0 4))) + ;; If user doesn't input units, then must use `calc-angle-mode'. + (should (string= (if (eq calc-angle-mode 'deg) + "9998" + "5403") + (substring + (number-to-string + (nth 1 (calcFunc-cos 1))) + 0 4)))))) + (provide 'calc-tests) ;;; calc-tests.el ends here commit eab1a6307b09180bd775cfb6bf7330eb5367bbe0 Author: Tino Calancha Date: Thu May 18 13:15:50 2017 +0900 Revert "Ignore angle mode while simplifying units" This reverts commit 713e922243fb60d850f7b0ff83f3e2a3682f1832. This commit causes Bug#25652. diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el index 6aa421ec20..abf76cf07e 100644 --- a/lisp/calc/calc-forms.el +++ b/lisp/calc/calc-forms.el @@ -317,9 +317,7 @@ (list 'calcFunc-hms a)) ((math-negp a) (math-neg (math-to-hms (math-neg a) ang))) - ((eq (or ang - (and (not math-simplifying-units) calc-angle-mode)) - 'rad) + ((eq (or ang calc-angle-mode) 'rad) (math-to-hms (math-div a (math-pi-over-180)) 'deg)) ((memq (car-safe a) '(cplx polar)) a) (t @@ -356,16 +354,12 @@ (if (eq (car-safe a) 'sdev) (math-make-sdev (math-from-hms (nth 1 a) ang) (math-from-hms (nth 2 a) ang)) - (if (eq (or ang - (and (not math-simplifying-units) calc-angle-mode)) - 'rad) + (if (eq (or ang calc-angle-mode) 'rad) (list 'calcFunc-rad a) (list 'calcFunc-deg a))))) ((math-negp a) (math-neg (math-from-hms (math-neg a) ang))) - ((eq (or ang - (and (not math-simplifying-units) calc-angle-mode)) - 'rad) + ((eq (or ang calc-angle-mode) 'rad) (math-mul (math-from-hms a 'deg) (math-pi-over-180))) (t (math-add (math-div (math-add (math-div (nth 3 a) diff --git a/lisp/calc/calc-math.el b/lisp/calc/calc-math.el index 2590761d53..faa318d45d 100644 --- a/lisp/calc/calc-math.el +++ b/lisp/calc/calc-math.el @@ -763,14 +763,12 @@ If this can't be done, return NIL." (defun math-to-radians (a) ; [N N] (cond ((eq (car-safe a) 'hms) (math-from-hms a 'rad)) - ((and (not math-simplifying-units) - (memq calc-angle-mode '(deg hms))) + ((memq calc-angle-mode '(deg hms)) (math-mul a (math-pi-over-180))) (t a))) (defun math-from-radians (a) ; [N N] - (cond ((and (not math-simplifying-units) - (eq calc-angle-mode 'deg)) + (cond ((eq calc-angle-mode 'deg) (if (math-constp a) (math-div a (math-pi-over-180)) (list 'calcFunc-deg a))) @@ -781,16 +779,14 @@ If this can't be done, return NIL." (defun math-to-radians-2 (a &optional force-symbolic) ; [N N] (cond ((eq (car-safe a) 'hms) (math-from-hms a 'rad)) - ((and (not math-simplifying-units) - (memq calc-angle-mode '(deg hms))) + ((memq calc-angle-mode '(deg hms)) (if (or calc-symbolic-mode force-symbolic) (math-div (math-mul a '(var pi var-pi)) 180) (math-mul a (math-pi-over-180)))) (t a))) (defun math-from-radians-2 (a &optional force-symbolic) ; [N N] - (cond ((and (not math-simplifying-units) - (memq calc-angle-mode '(deg hms))) + (cond ((memq calc-angle-mode '(deg hms)) (if (or calc-symbolic-mode force-symbolic) (math-div (math-mul 180 a) '(var pi var-pi)) (math-div a (math-pi-over-180)))) commit d4cac417d6d09004390e929b21cd3a2de9f48e0d Author: Paul Eggert Date: Wed May 17 14:58:54 2017 -0700 ; Spelling fix diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a438052e00..9b25ead37f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ # GNU Emacs support for the GitLab protocol for CI # The presence of this file does not imply any FSF/GNU endorsement of -# any particular servce that uses that protocol. Also, it is intended for +# any particular service that uses that protocol. Also, it is intended for # evaluation purposes, thus possibly temporary. # Maintainer: tzz@lifelogs.com commit e54a3b4fde0c3de7964a2e604c7381101e5d9951 Author: Paul Eggert Date: Wed May 17 13:35:52 2017 -0700 Avoid undefined behavior in struct sockaddr Problem noted by Philipp Stephani in: http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00391.html * src/conf_post.h (ATTRIBUTE_MAY_ALIAS, DECLARE_POINTER_ALIAS): New macros. * src/process.c (conv_sockaddr_to_lisp, conv_lisp_to_sockaddr) (connect_network_socket, network_interface_info) (server_accept_connection): Use it when aliasing non-char objects. diff --git a/src/conf_post.h b/src/conf_post.h index 1462bd16c7..c05c93b819 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -263,6 +263,20 @@ extern int emacs_setenv_TZ (char const *); #define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST #define ATTRIBUTE_UNUSED _GL_UNUSED +#if GNUC_PREREQ (3, 3, 0) +# define ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) +#else +# define ATTRIBUTE_MAY_ALIAS +#endif + +/* Declare NAME to be a pointer to an object of type TYPE, initialized + to the address ADDR, which may be of a different type. Accesses + via NAME may alias with other accesses with the traditional + behavior, even if options like gcc -fstrict-aliasing are used. */ + +#define DECLARE_POINTER_ALIAS(name, type, addr) \ + type ATTRIBUTE_MAY_ALIAS *name = (type *) (addr) + #if 3 <= __GNUC__ # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) #else diff --git a/src/process.c b/src/process.c index 8180feaba9..c30173955d 100644 --- a/src/process.c +++ b/src/process.c @@ -2476,7 +2476,7 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len) { case AF_INET: { - struct sockaddr_in *sin = (struct sockaddr_in *) sa; + DECLARE_POINTER_ALIAS (sin, struct sockaddr_in, sa); len = sizeof (sin->sin_addr) + 1; address = Fmake_vector (make_number (len), Qnil); p = XVECTOR (address); @@ -2487,8 +2487,8 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len) #ifdef AF_INET6 case AF_INET6: { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa; - uint16_t *ip6 = (uint16_t *) &sin6->sin6_addr; + DECLARE_POINTER_ALIAS (sin6, struct sockaddr_in6, sa); + DECLARE_POINTER_ALIAS (ip6, uint16_t, &sin6->sin6_addr); len = sizeof (sin6->sin6_addr) / 2 + 1; address = Fmake_vector (make_number (len), Qnil); p = XVECTOR (address); @@ -2501,7 +2501,7 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len) #ifdef HAVE_LOCAL_SOCKETS case AF_LOCAL: { - struct sockaddr_un *sockun = (struct sockaddr_un *) sa; + DECLARE_POINTER_ALIAS (sockun, struct sockaddr_un, sa); ptrdiff_t name_length = len - offsetof (struct sockaddr_un, sun_path); /* If the first byte is NUL, the name is a Linux abstract socket name, and the name can contain embedded NULs. If @@ -2612,7 +2612,7 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int p = XVECTOR (address); if (family == AF_INET) { - struct sockaddr_in *sin = (struct sockaddr_in *) sa; + DECLARE_POINTER_ALIAS (sin, struct sockaddr_in, sa); len = sizeof (sin->sin_addr) + 1; hostport = XINT (p->contents[--len]); sin->sin_port = htons (hostport); @@ -2622,8 +2622,8 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int #ifdef AF_INET6 else if (family == AF_INET6) { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa; - uint16_t *ip6 = (uint16_t *)&sin6->sin6_addr; + DECLARE_POINTER_ALIAS (sin6, struct sockaddr_in6, sa); + DECLARE_POINTER_ALIAS (ip6, uint16_t, &sin6->sin6_addr); len = sizeof (sin6->sin6_addr) / 2 + 1; hostport = XINT (p->contents[--len]); sin6->sin6_port = htons (hostport); @@ -2645,7 +2645,7 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int #ifdef HAVE_LOCAL_SOCKETS if (family == AF_LOCAL) { - struct sockaddr_un *sockun = (struct sockaddr_un *) sa; + DECLARE_POINTER_ALIAS (sockun, struct sockaddr_un, sa); cp = SDATA (address); for (i = 0; i < sizeof (sockun->sun_path) && *cp; i++) sockun->sun_path[i] = *cp++; @@ -3436,13 +3436,15 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, == offsetof (struct sockaddr_in6, sin6_port)) && sizeof (sa1.sin_port) == sizeof (sa6.sin6_port)); #endif - if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) + DECLARE_POINTER_ALIAS (psa1, struct sockaddr, &sa1); + if (getsockname (s, psa1, &len1) == 0) { Lisp_Object service = make_number (ntohs (sa1.sin_port)); contact = Fplist_put (contact, QCservice, service); /* Save the port number so that we can stash it in the process object later. */ - ((struct sockaddr_in *) sa)->sin_port = sa1.sin_port; + DECLARE_POINTER_ALIAS (psa, struct sockaddr_in, sa); + psa->sin_port = sa1.sin_port; } } #endif @@ -3550,9 +3552,10 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, { struct sockaddr_storage sa1; socklen_t len1 = sizeof (sa1); - if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) + DECLARE_POINTER_ALIAS (psa1, struct sockaddr, &sa1); + if (getsockname (s, psa1, &len1) == 0) contact = Fplist_put (contact, QClocal, - conv_sockaddr_to_lisp ((struct sockaddr *)&sa1, len1)); + conv_sockaddr_to_lisp (psa1, len1)); } #endif } @@ -4401,7 +4404,7 @@ network_interface_info (Lisp_Object ifname) for (it = ifap; it != NULL; it = it->ifa_next) { - struct sockaddr_dl *sdl = (struct sockaddr_dl *) it->ifa_addr; + DECLARE_POINTER_ALIAS (sdl, struct sockaddr_dl, it->ifa_addr); unsigned char linkaddr[6]; int n; @@ -4722,7 +4725,7 @@ server_accept_connection (Lisp_Object server, int channel) { args[nargs++] = procname_format_in6; nargs++; - uint16_t *ip6 = (uint16_t *)&saddr.in6.sin6_addr; + DECLARE_POINTER_ALIAS (ip6, uint16_t, &saddr.in6.sin6_addr); service = make_number (ntohs (saddr.in.sin_port)); for (int i = 0; i < 8; i++) args[nargs++] = make_number (ip6[i]); commit 184d74ce002ecb7399cb2b47fc671bfb2feb9855 Author: Stefan Monnier Date: Wed May 17 15:44:36 2017 -0400 * lisp/vc/smerge-mode.el (smerge-refine-regions): Work in multi-bufs Rename from smerge-refine-subst. Allow the `beg's to be markers. Add autoload cookie. (smerge--refine-forward): Rename from smerge-refine-forward. (smerge--refine-chopup-region): Rename from smerge-refine-chopup-region. Assume that its `beg` arg is a marker. (smerge--refine-highlight-change): Rename from smerge-refine-highlight-change. Remove `buf` arg. (smerge-refine-subst): Redefine as an obsolete alias. diff --git a/etc/NEWS b/etc/NEWS index 6667a44c29..6851dc9a0e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -415,6 +415,8 @@ line. * Changes in Specialized Modes and Packages in Emacs 26.1 +*** smerge-refine-regions can refine regions in separate buffers + *** Info menu and index completion uses substring completion by default. This can be customized via the info-menu category in completion-category-override. diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el index de40b99b94..21c39c85ca 100644 --- a/lisp/vc/smerge-mode.el +++ b/lisp/vc/smerge-mode.el @@ -911,7 +911,7 @@ Point is moved to the end of the conflict." ;;; Refined change highlighting -(defvar smerge-refine-forward-function 'smerge-refine-forward +(defvar smerge-refine-forward-function #'smerge--refine-forward "Function used to determine an \"atomic\" element. You can set it to `forward-char' to get char-level granularity. Its behavior has mainly two restrictions: @@ -941,7 +941,7 @@ It has the following disadvantages: - may in degenerate cases take a 1KB input region and turn it into a 1MB file to pass to diff.") -(defun smerge-refine-forward (n) +(defun smerge--refine-forward (n) (let ((case-fold-search nil) (re "[[:upper:]]?[[:lower:]]+\\|[[:upper:]]+\\|[[:digit:]]+\\|.\\|\n")) (when (and smerge-refine-ignore-whitespace @@ -954,7 +954,7 @@ It has the following disadvantages: (unless (looking-at re) (error "Smerge refine internal error")) (goto-char (match-end 0))))) -(defun smerge-refine-chopup-region (beg end file &optional preproc) +(defun smerge--refine-chopup-region (beg end file &optional preproc) "Chopup the region into small elements, one per line. Save the result into FILE. If non-nil, PREPROC is called with no argument in a buffer that contains @@ -966,44 +966,45 @@ chars to try and eliminate some spurious differences." ;; there aren't any, so the resulting "change" didn't make much sense. ;; You can still get this behavior by setting ;; `smerge-refine-forward-function' to `forward-char'. - (let ((buf (current-buffer))) - (with-temp-buffer - (insert-buffer-substring buf beg end) - (when preproc (goto-char (point-min)) (funcall preproc)) - (when smerge-refine-ignore-whitespace - ;; It doesn't make much of a difference for diff-fine-highlight - ;; because we still have the _/+//! prefix anyway. Can still be - ;; useful in other circumstances. - (subst-char-in-region (point-min) (point-max) ?\n ?\s)) - (goto-char (point-min)) - (while (not (eobp)) - (funcall smerge-refine-forward-function 1) - (let ((s (if (prog2 (forward-char -1) (bolp) (forward-char 1)) - nil - (buffer-substring (line-beginning-position) (point))))) - ;; We add \n after each char except after \n, so we get - ;; one line per text char, where each line contains - ;; just one char, except for \n chars which are - ;; represented by the empty line. - (unless (eq (char-before) ?\n) (insert ?\n)) - ;; HACK ALERT!! - (if smerge-refine-weight-hack - (dotimes (_i (1- (length s))) (insert s "\n"))))) - (unless (bolp) (error "Smerge refine internal error")) - (let ((coding-system-for-write 'emacs-mule)) - (write-region (point-min) (point-max) file nil 'nomessage))))) - -(defun smerge-refine-highlight-change (buf beg match-num1 match-num2 props) - (with-current-buffer buf + (with-temp-buffer + (insert-buffer-substring (marker-buffer beg) beg end) + (when preproc (goto-char (point-min)) (funcall preproc)) + (when smerge-refine-ignore-whitespace + ;; It doesn't make much of a difference for diff-fine-highlight + ;; because we still have the _/+//! prefix anyway. Can still be + ;; useful in other circumstances. + (subst-char-in-region (point-min) (point-max) ?\n ?\s)) + (goto-char (point-min)) + (while (not (eobp)) + (funcall smerge-refine-forward-function 1) + (let ((s (if (prog2 (forward-char -1) (bolp) (forward-char 1)) + nil + (buffer-substring (line-beginning-position) (point))))) + ;; We add \n after each char except after \n, so we get + ;; one line per text char, where each line contains + ;; just one char, except for \n chars which are + ;; represented by the empty line. + (unless (eq (char-before) ?\n) (insert ?\n)) + ;; HACK ALERT!! + (if smerge-refine-weight-hack + (dotimes (_i (1- (length s))) (insert s "\n"))))) + (unless (bolp) (error "Smerge refine internal error")) + (let ((coding-system-for-write 'emacs-internal)) + (write-region (point-min) (point-max) file nil 'nomessage)))) + +(defun smerge--refine-highlight-change (beg match-num1 match-num2 props) + ;; TODO: Add a property pointing to the corresponding text in the + ;; other region. + (with-current-buffer (marker-buffer beg) (goto-char beg) (let* ((startline (- (string-to-number match-num1) 1)) (beg (progn (funcall (if smerge-refine-weight-hack - 'forward-char + #'forward-char smerge-refine-forward-function) startline) (point))) (end (progn (funcall (if smerge-refine-weight-hack - 'forward-char + #'forward-char smerge-refine-forward-function) (if match-num2 (- (string-to-number match-num2) @@ -1023,7 +1024,8 @@ chars to try and eliminate some spurious differences." (dolist (x props) (overlay-put ol (car x) (cdr x))) ol))))) -(defun smerge-refine-subst (beg1 end1 beg2 end2 props-c &optional preproc props-r props-a) +;;;###autoload +(defun smerge-refine-regions (beg1 end1 beg2 end2 props-c &optional preproc props-r props-a) "Show fine differences in the two regions BEG1..END1 and BEG2..END2. PROPS-C is an alist of properties to put (via overlays) on the changes. PROPS-R is an alist of properties to put on removed characters. @@ -1037,19 +1039,20 @@ PROPS-A on added characters, and PROPS-R on removed characters. If non-nil, PREPROC is called with no argument in a buffer that contains a copy of a region, just before preparing it to for `diff'. It can be used to replace chars to try and eliminate some spurious differences." - (let* ((buf (current-buffer)) - (pos (point)) + (let* ((pos (point)) deactivate-mark ; The code does not modify any visible buffer. (file1 (make-temp-file "diff1")) (file2 (make-temp-file "diff2"))) + (unless (markerp beg1) (setq beg1 (copy-marker beg1))) + (unless (markerp beg2) (setq beg2 (copy-marker beg2))) ;; Chop up regions into smaller elements and save into files. - (smerge-refine-chopup-region beg1 end1 file1 preproc) - (smerge-refine-chopup-region beg2 end2 file2 preproc) + (smerge--refine-chopup-region beg1 end1 file1 preproc) + (smerge--refine-chopup-region beg2 end2 file2 preproc) ;; Call diff on those files. (unwind-protect (with-temp-buffer - (let ((coding-system-for-read 'emacs-mule)) + (let ((coding-system-for-read 'emacs-internal)) (call-process diff-command nil t nil (if (and smerge-refine-ignore-whitespace (not smerge-refine-weight-hack)) @@ -1077,16 +1080,16 @@ used to replace chars to try and eliminate some spurious differences." (m5 (match-string 5))) (when (memq op '(?d ?c)) (setq last1 - (smerge-refine-highlight-change - buf beg1 m1 m2 + (smerge--refine-highlight-change + beg1 m1 m2 ;; Try to use props-c only for changed chars, ;; fallback to props-r for changed/removed chars, ;; but if props-r is nil then fallback to props-c. (or (and (eq op '?c) props-c) props-r props-c)))) (when (memq op '(?a ?c)) (setq last2 - (smerge-refine-highlight-change - buf beg2 m4 m5 + (smerge--refine-highlight-change + beg2 m4 m5 ;; Same logic as for removed chars above. (or (and (eq op '?c) props-c) props-a props-c))))) (forward-line 1) ;Skip hunk header. @@ -1110,6 +1113,8 @@ used to replace chars to try and eliminate some spurious differences." (goto-char pos) (delete-file file1) (delete-file file2)))) +(define-obsolete-function-alias 'smerge-refine-subst + #'smerge-refine-regions "26.1") (defun smerge-refine (&optional part) "Highlight the words of the conflict that are different. commit 709259dcc501ef991991a35a6ffb2aef02a62c60 Author: Paul Eggert Date: Wed May 17 10:58:11 2017 -0700 Work around AddressSanitizer bug with vfork Problem reported by Jim Meyering in: http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00246.html * src/conf_post.h (vfork) [ADDRESS_SANITIZER]: Define to fork. Unfortunately with the AddressSanitizer in Fedora 25 x86-64, the vforked child messes up the parent’s shadow memory. This is too bad, as we’d rather have AddressSanitizer catch memory-access bugs related to vfork. diff --git a/src/conf_post.h b/src/conf_post.h index 4fc0428df5..1462bd16c7 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -302,6 +302,12 @@ extern int emacs_setenv_TZ (char const *); # define ATTRIBUTE_NO_SANITIZE_ADDRESS #endif +/* gcc -fsanitize=address does not work with vfork in Fedora 25 x86-64. + For now, assume that this problem occurs on all platforms. */ +#if ADDRESS_SANITIZER && !defined vfork +# define vfork fork +#endif + /* Some versions of GNU/Linux define noinline in their headers. */ #ifdef noinline #undef noinline commit 937ff1a0af1813875f851987ca5c4ac833ca3c97 Author: Paul Eggert Date: Wed May 17 10:27:31 2017 -0700 Catch IPv4/IPv6 issues at compile time * src/process.c (connect_network_socket): Use verify, not eassert, so that any problems are caught at compile-time. Avoid dodgy cast by using a local var of the correct type. diff --git a/src/process.c b/src/process.c index ecb1b0ca6d..8180feaba9 100644 --- a/src/process.c +++ b/src/process.c @@ -3430,11 +3430,11 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, /* The code below assumes the port is at the same offset and of the same width in both IPv4 and IPv6 structures, but the standards don't guarantee that, - so we have this assertion to make sure. */ - eassert ((offsetof (struct sockaddr_in, sin_port) - == offsetof (struct sockaddr_in6, sin6_port)) - && (sizeof (sa1.sin_port) - == sizeof (((struct sockaddr_in6 *) &sa1)->sin6_port))); + so verify it here. */ + struct sockaddr_in6 sa6; + verify ((offsetof (struct sockaddr_in, sin_port) + == offsetof (struct sockaddr_in6, sin6_port)) + && sizeof (sa1.sin_port) == sizeof (sa6.sin6_port)); #endif if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) { commit 2b93b754c108f620428eaf9b193eeb321f3010db Author: Paul Eggert Date: Wed May 17 10:25:21 2017 -0700 Pacify --enable-gcc-warnings --with-x-toolkit=no * src/composite.c (autocmp_chars) [!HAVE_WINDOW_SYSTEM]: Avoid unused local. diff --git a/src/composite.c b/src/composite.c index b673c53ac8..05a296329a 100644 --- a/src/composite.c +++ b/src/composite.c @@ -867,7 +867,6 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, Lisp_Object string) { ptrdiff_t count = SPECPDL_INDEX (); - struct frame *f = XFRAME (win->frame); Lisp_Object pos = make_number (charpos); ptrdiff_t to; ptrdiff_t pt = PT, pt_byte = PT_BYTE; @@ -893,6 +892,7 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, to = limit = charpos + len; font_object = win->frame; #ifdef HAVE_WINDOW_SYSTEM + struct frame *f = XFRAME (font_object); if (FRAME_WINDOW_P (f)) { font_object = font_range (charpos, bytepos, &to, win, face, string); commit 1b598d32aa06128fb5d9faa634118360e68a73c7 Author: Glenn Morris Date: Wed May 17 12:44:29 2017 -0400 * admin/update_autogen (commit): Pull before push. diff --git a/admin/update_autogen b/admin/update_autogen index 898432eae6..9393ab0ee9 100755 --- a/admin/update_autogen +++ b/admin/update_autogen @@ -237,6 +237,8 @@ commit () $vcs commit -m "; Auto-commit of $type files." "$@" || return $? [ "$vcs" = "git" ] && { + ## In case someone else pushed something while we were working. + $vcs pull --rebase || return $? $vcs push || return $? } commit df4e105910a983f42e77828809ab50611b454905 Author: Glenn Morris Date: Wed May 17 12:43:23 2017 -0400 autoload-rubric no longer provides a feature by default * lisp/emacs-lisp/autoload.el (autoload-rubric): Stop providing a feature unless explicitly requested. (autoload-find-generated-file): Update autoload-rubric call. diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index f6b09dcf31..8fe9401370 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -264,7 +264,7 @@ expression, in which case we want to handle forms differently." ;; problems when the file contains non-ASCII characters. (with-current-buffer (find-file-noselect (autoload-ensure-file-writeable file)) - (if (zerop (buffer-size)) (insert (autoload-rubric file))) + (if (zerop (buffer-size)) (insert (autoload-rubric file nil t))) (current-buffer)))) (defun autoload-generated-file () @@ -360,10 +360,7 @@ but adds an extra line to the output to modify `load-path'. If FEATURE is non-nil, FILE will provide a feature. FEATURE may be a string naming the feature, otherwise it will be based on -FILE's name. - -At present, a feature is in fact always provided, but this should -not be relied upon." +FILE's name." (let ((basename (file-name-nondirectory file)) (lp (if (equal type "package") (setq type "autoloads")))) (concat ";;; " basename @@ -372,15 +369,14 @@ not be relied upon." ";;; Code:\n\n" (if lp ;; `load-path' should contain only directory names. - "(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n \n" - (concat - ;; This is used outside of autoload.el, eg cus-dep, finder. - " \n" - "(provide '" - (if (stringp feature) - feature - (file-name-sans-extension basename)) - ")\n")) + "(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path))))\n\n") + " \n" + ;; This is used outside of autoload.el, eg cus-dep, finder. + (if feature + (format "(provide '%s)\n" + (if (stringp feature) feature + (file-name-sans-extension basename)))) ";; Local Variables:\n" ";; version-control: never\n" ";; no-byte-compile: t\n" commit f861353b684e5c40dade61f89fd1742e4226a282 Author: Eli Zaretskii Date: Wed May 17 18:12:58 2017 +0300 Remove redundant code in connect_network_socket * src/process.c (connect_network_socket) [HAVE_GETSOCKNAME]: Remove redundant type-casting and variables. Don't call 'getsockname' to find the port for AF_LOCAL sockets. [AF_INET6]: Add an assertion to verify that the ports in the IPv4 and IPv6 structures are at the same offset and have the same size. diff --git a/src/process.c b/src/process.c index fdea97722f..ecb1b0ca6d 100644 --- a/src/process.c +++ b/src/process.c @@ -3418,34 +3418,31 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, report_file_error ("Cannot bind server socket", Qnil); #ifdef HAVE_GETSOCKNAME - if (p->port == 0) + if (p->port == 0 +#ifdef HAVE_LOCAL_SOCKETS + && family != AF_LOCAL +#endif + ) { - struct sockaddr_storage sa1; + struct sockaddr_in sa1; socklen_t len1 = sizeof (sa1); +#ifdef AF_INET6 + /* The code below assumes the port is at the same offset + and of the same width in both IPv4 and IPv6 + structures, but the standards don't guarantee that, + so we have this assertion to make sure. */ + eassert ((offsetof (struct sockaddr_in, sin_port) + == offsetof (struct sockaddr_in6, sin6_port)) + && (sizeof (sa1.sin_port) + == sizeof (((struct sockaddr_in6 *) &sa1)->sin6_port))); +#endif if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) { + Lisp_Object service = make_number (ntohs (sa1.sin_port)); + contact = Fplist_put (contact, QCservice, service); /* Save the port number so that we can stash it in the process object later. */ - int port = -1; - switch (family) - { - case AF_INET: - ((struct sockaddr_in *) sa)->sin_port - = port = ((struct sockaddr_in *) &sa1)->sin_port; - break; -# ifdef AF_INET6 - case AF_INET6: - ((struct sockaddr_in6 *) sa)->sin6_port - = port = ((struct sockaddr_in6 *) &sa1)->sin6_port; - break; -# endif - } - - if (0 <= port) - { - Lisp_Object service = make_number (ntohs (port)); - contact = Fplist_put (contact, QCservice, service); - } + ((struct sockaddr_in *) sa)->sin_port = sa1.sin_port; } } #endif