commit 9341142dc876f4d93c442242206a7d2d40fd03af (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Mon Jun 20 02:05:39 2016 +0200 Minor ABLOCKS_BUSY cleanups in alloc.c * src/alloc.c (ABLOCKS_BUSY): Rename arg to avoid potential clash with member ‘abase’ in definiens. (lisp_align_malloc, lisp_align_free): Use bool for boolean. Avoid compiler warning with fewer casts. (lisp_align_free): Check busy-field values; this can help the compiler a bit when optimizing, too. diff --git a/src/alloc.c b/src/alloc.c index 0a3e7d4..5f9d6ad 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1178,16 +1178,18 @@ struct ablock char payload[BLOCK_BYTES]; struct ablock *next_free; } x; - /* `abase' is the aligned base of the ablocks. */ - /* It is overloaded to hold the virtual `busy' field that counts - the number of used ablock in the parent ablocks. - The first ablock has the `busy' field, the others have the `abase' - field. To tell the difference, we assume that pointers will have - integer values larger than 2 * ABLOCKS_SIZE. The lowest bit of `busy' - is used to tell whether the real base of the parent ablocks is `abase' - (if not, the word before the first ablock holds a pointer to the - real base). */ + + /* ABASE is the aligned base of the ablocks. It is overloaded to + hold a virtual "busy" field that counts twice the number of used + ablock values in the parent ablocks, plus one if the real base of + the parent ablocks is ABASE (if the "busy" field is even, the + word before the first ablock holds a pointer to the real base). + The first ablock has a "busy" ABASE, and the others have an + ordinary pointer ABASE. To tell the difference, the code assumes + that pointers, when cast to uintptr_t, are at least 2 * + ABLOCKS_SIZE + 1. */ struct ablocks *abase; + /* The padding of all but the last ablock is unused. The padding of the last ablock in an ablocks is not allocated. */ #if BLOCK_PADDING @@ -1206,18 +1208,18 @@ struct ablocks #define ABLOCK_ABASE(block) \ (((uintptr_t) (block)->abase) <= (1 + 2 * ABLOCKS_SIZE) \ - ? (struct ablocks *)(block) \ + ? (struct ablocks *) (block) \ : (block)->abase) /* Virtual `busy' field. */ -#define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase) +#define ABLOCKS_BUSY(a_base) ((a_base)->blocks[0].abase) /* Pointer to the (not necessarily aligned) malloc block. */ #ifdef USE_ALIGNED_ALLOC #define ABLOCKS_BASE(abase) (abase) #else #define ABLOCKS_BASE(abase) \ - (1 & (intptr_t) ABLOCKS_BUSY (abase) ? abase : ((void **)abase)[-1]) + (1 & (intptr_t) ABLOCKS_BUSY (abase) ? abase : ((void **) (abase))[-1]) #endif /* The list of free ablock. */ @@ -1243,7 +1245,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type) if (!free_ablock) { int i; - intptr_t aligned; /* int gets warning casting to 64-bit pointer. */ + bool aligned; #ifdef DOUG_LEA_MALLOC if (!mmap_lisp_allowed_p ()) @@ -1299,13 +1301,14 @@ lisp_align_malloc (size_t nbytes, enum mem_type type) abase->blocks[i].x.next_free = free_ablock; free_ablock = &abase->blocks[i]; } - ABLOCKS_BUSY (abase) = (struct ablocks *) aligned; + intptr_t ialigned = aligned; + ABLOCKS_BUSY (abase) = (struct ablocks *) ialigned; - eassert (0 == ((uintptr_t) abase) % BLOCK_ALIGN); + eassert ((uintptr_t) abase % BLOCK_ALIGN == 0); eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */ eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase); eassert (ABLOCKS_BASE (abase) == base); - eassert (aligned == (intptr_t) ABLOCKS_BUSY (abase)); + eassert ((intptr_t) ABLOCKS_BUSY (abase) == aligned); } abase = ABLOCK_ABASE (free_ablock); @@ -1341,12 +1344,14 @@ lisp_align_free (void *block) ablock->x.next_free = free_ablock; free_ablock = ablock; /* Update busy count. */ - ABLOCKS_BUSY (abase) - = (struct ablocks *) (-2 + (intptr_t) ABLOCKS_BUSY (abase)); + intptr_t busy = (intptr_t) ABLOCKS_BUSY (abase) - 2; + eassume (0 <= busy && busy <= 2 * ABLOCKS_SIZE - 1); + ABLOCKS_BUSY (abase) = (struct ablocks *) busy; - if (2 > (intptr_t) ABLOCKS_BUSY (abase)) + if (busy < 2) { /* All the blocks are free. */ - int i = 0, aligned = (intptr_t) ABLOCKS_BUSY (abase); + int i = 0; + bool aligned = busy; struct ablock **tem = &free_ablock; struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1]; commit dd39c6fbeb299f0b203f01388e83f5e02767b8ff Author: Dmitry Gutov Date: Sun Jun 19 22:08:21 2016 +0300 ASCII-fy coding-system-for-read used for Git commands * lisp/vc/vc-git.el (vc-git--asciify-coding-system): New function. (vc-git-diff, vc-git-annotate-command): Use it. diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 16cbeef..783ea89 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1084,6 +1084,13 @@ or BRANCH^ (where \"^\" can be repeated)." (cons 'vc-git-region-history-font-lock-keywords (cdr font-lock-defaults)))) +(defun vc-git--asciify-coding-system () + ;; Try to reconcile the content encoding with the encoding of Git's + ;; auxiliary output (which is ASCII or ASCII-compatible), bug#23595. + (unless (let ((samp "Binary files differ")) + (string-equal samp (decode-coding-string + samp coding-system-for-read t))) + (setq coding-system-for-read 'undecided))) (autoload 'vc-switches "vc") @@ -1091,6 +1098,7 @@ or BRANCH^ (where \"^\" can be repeated)." "Get a difference report using Git between two revisions of FILES." (let (process-file-side-effects (command "diff-tree")) + (vc-git--asciify-coding-system) (if rev2 ;; Diffing against the empty tree. (unless rev1 (setq rev1 "4b825dc642cb6eb9a060e54bf8d69288fbee4904")) @@ -1129,6 +1137,7 @@ or BRANCH^ (where \"^\" can be repeated)." table)) (defun vc-git-annotate-command (file buf &optional rev) + (vc-git--asciify-coding-system) (let ((name (file-relative-name file))) (apply #'vc-git-command buf 'async nil "blame" "--date=short" (append (vc-switches 'git 'annotate) commit 2ede29575fa22eb7c265117d7511cff9fe02c606 Author: Dmitry Gutov Date: Sun Jun 19 21:06:39 2016 +0300 Prohibit multibyte characters in url-http-data It didn't work anyway, but this makes any such errors more obvious by catching them earlier. * lisp/url/url-http.el (url-http-create-request): Use string-to-unibyte (bug#23750). diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 306b36a..0e6f5d3 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -310,14 +310,10 @@ The string is based on `url-privacy-level' and `url-user-agent'." ;; We used to concat directly, but if one of the strings happens ;; to being multibyte (even if it only contains pure ASCII) then ;; every string gets converted with `string-MAKE-multibyte' which - ;; turns the 127-255 codes into things like latin-1 accented chars - ;; (it would work right if it used `string-TO-multibyte' instead). + ;; turns the 127-255 codes into things like latin-1 accented chars. ;; So to avoid the problem we force every string to be unibyte. (mapconcat - ;; FIXME: Instead of `string-AS-unibyte' we'd want - ;; `string-to-unibyte', so as to properly signal an error if one - ;; of the strings contains a multibyte char. - 'string-as-unibyte + 'string-to-unibyte (delq nil (list ;; The request commit ea5d141882b5b0519abc8f50f28a43b9ae41c50d Author: Eli Zaretskii Date: Sun Jun 19 18:25:17 2016 +0300 Fix setting a range of char-table slots in a singular case * src/chartab.c (char_table_set_range): Start the loop from the first character of the block to which FROM belongs. (Bug#23797) * test/src/chartab-tests.el: New test file. diff --git a/src/chartab.c b/src/chartab.c index 6cf8fea..fa5a8e4 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -492,7 +492,7 @@ char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val) int lim = CHARTAB_IDX (to, 0, 0); int i, c; - for (i = CHARTAB_IDX (from, 0, 0), c = 0; i <= lim; + for (i = CHARTAB_IDX (from, 0, 0), c = i * chartab_chars[0]; i <= lim; i++, c += chartab_chars[0]) { if (c > to) diff --git a/test/src/chartab-tests.el b/test/src/chartab-tests.el new file mode 100644 index 0000000..016ddcd --- /dev/null +++ b/test/src/chartab-tests.el @@ -0,0 +1,51 @@ +;;; chartab-tests.el --- Tests for char-tab.c + +;; Copyright (C) 2016 Free Software Foundation, Inc. + +;; Author: Eli Zaretskii + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Code: + +(require 'ert) + +(defun chartab-set-and-test (rng) + (let ((tbl (make-char-table nil nil)) + (from (car rng)) + (to (cdr rng))) + (set-char-table-range tbl rng t) + (should (eq (aref tbl from) t)) + (should (eq (aref tbl to) t)) + (should (eq (aref tbl (/ (+ from to) 2)) t)) + (when (< to (max-char)) + (should-not (eq (aref tbl (1+ to)) t))) + (when (> from 0) + (should-not (eq (aref tbl (1- from)) t))))) + +(ert-deftest chartab-test-range-setting () + (mapc (lambda (elt) + (chartab-set-and-test elt)) + '((0 . 127) + (128 . 256) + (#x1000 . #x1fff) + (#x1001 . #x2000) + (#x10000 . #x20000) + (#x10001 . #x1ffff) + (#x20000 . #x30000) + (#xe0e00 . #xe0ef6) + ))) + +(provide 'chartab-tests) +;;; chartab-tests.el ends here commit 4e9014f02574039ba7d131fba94af728efd41397 Author: Alan Mackenzie Date: Sun Jun 19 12:06:24 2016 +0000 Fix CC Mode fontification problem apparent in test file decls-6.cc. * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): Recognize "bar (gnu);" as a declarator only when the construct is directly inside a class (etc.) called "bar". (c-directly-in-class-called-p): New function. diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 011d080..595d577 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -7966,16 +7966,32 @@ comment at the start of cc-engine.el for more info." maybe-typeless backup-maybe-typeless (eq at-decl-or-cast t) + ;; Check whether we have "bar (gnu);" where we + ;; are directly inside a class (etc.) called "bar". (save-excursion - (goto-char name-start) - (not (memq (c-forward-type) '(nil maybe)))))) + (and + (progn + (goto-char name-start) + (not (memq (c-forward-type) '(nil maybe)))) + (progn + (goto-char id-start) + (c-directly-in-class-called-p + (buffer-substring + type-start + (progn + (goto-char type-start) + (c-forward-type) + (c-backward-syntactic-ws) + (point))))))))) ;; Got a declaration of the form "foo bar (gnu);" or "bar ;; (gnu);" where we've recognized "bar" as the type and "gnu" - ;; as the declarator. In this case it's however more likely - ;; that "bar" is the declarator and "gnu" a function argument - ;; or initializer (if `c-recognize-paren-inits' is set), - ;; since the parens around "gnu" would be superfluous if it's - ;; a declarator. Shift the type one step backward. + ;; as the declarator, and in the latter case, checked that + ;; "bar (gnu)" appears directly inside the class "bar". In + ;; this case it's however more likely that "bar" is the + ;; declarator and "gnu" a function argument or initializer + ;; (if `c-recognize-paren-inits' is set), since the parens + ;; around "gnu" would be superfluous if it's a declarator. + ;; Shift the type one step backward. (c-fdoc-shift-type-backward))) ;; Found no identifier. @@ -9414,6 +9430,26 @@ comment at the start of cc-engine.el for more info." kwd-start))) +(defun c-directly-in-class-called-p (name) + ;; Check whether point is directly inside a brace block which is the brace + ;; block of a class, struct, or union which is called NAME, a string. + (let* ((paren-state (c-parse-state)) + (brace-pos (c-pull-open-brace paren-state)) + ) + (when (eq (char-after brace-pos) ?{) + (goto-char brace-pos) + (save-excursion + ; *c-looking-at-decl-block + ; containing-sexp goto-start &optional + ; limit) + (when (and (c-looking-at-decl-block + (c-pull-open-brace paren-state) + nil) + (looking-at c-class-key)) + (goto-char (match-end 1)) + (c-forward-syntactic-ws) + (looking-at name)))))) + (defun c-search-uplist-for-classkey (paren-state) ;; Check if the closest containing paren sexp is a declaration ;; block, returning a 2 element vector in that case. Aref 0 commit 65885ccf29ce4723f100a45756005781e8e7ab46 Author: Alan Mackenzie Date: Sun Jun 19 11:25:07 2016 +0000 c-renarrow-state-cache: take care when new point is inside old brace pair. Also add display of point-min to the c-parse-state debugging output. * lisp/progmodes/cc-engine.el (c-renarrow-state-cache): When the new point is inside an old recorded brace pair, clear the cache. (c-debug-parse-state): Output the value of point-min. diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 32eca3e..011d080 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -2752,7 +2752,11 @@ comment at the start of cc-engine.el for more info." (setq ptr (cdr ptr))) (when (consp ptr) - (if (eq (cdr ptr) c-state-cache) + (if (or (eq (cdr ptr) c-state-cache) + (and (consp (cadr ptr)) + (> (cdr (cadr ptr)) (point-min)))) ; Our new point-min is + ; inside a recorded + ; brace pair. (setq c-state-cache nil c-state-cache-good-pos c-state-min-scan-pos) (setcdr ptr nil) @@ -3603,7 +3607,7 @@ comment at the start of cc-engine.el for more info." conses-not-ok)) (defun c-debug-parse-state () - (let ((here (point)) (res1 (c-real-parse-state)) res2) + (let ((here (point)) (min-point (point-min)) (res1 (c-real-parse-state)) res2) (let ((c-state-cache nil) (c-state-cache-good-pos 1) (c-state-nonlit-pos-cache nil) @@ -3630,8 +3634,8 @@ comment at the start of cc-engine.el for more info." ;; "using cache: %s, from scratch: %s") ;; here res1 res2))) (message (concat "c-parse-state inconsistency at %s: " - "using cache: %s, from scratch: %s") - here res1 res2) + "using cache: %s, from scratch: %s. POINT-MIN: %s") + here res1 res2 min-point) (message "Old state:") (c-replay-parse-state-state))