commit/XEmacs: kehoea: Give the correct bounding keywords to
#'parse-integer in #'about-xemacs
7 years, 6 months
Bitbucket
1 new commit in XEmacs:
https://bitbucket.org/xemacs/xemacs/commits/b803128e4209/
Changeset: b803128e4209
User: kehoea
Date: 2017-05-30 19:30:25+00:00
Summary: Give the correct bounding keywords to #'parse-integer in #'about-xemacs
lisp/ChangeLog addition:
2017-05-30 Aidan Kehoe <kehoea(a)parhasard.net>
* about.el (about-xemacs):
Correct a recently-introduced bug here, give the correct bounding
keywords to #'parse-integer when working out the month of the
release date.
Don't check for xemacs-extra-name, xemacs-release-date being
#'boundp, we control src/emacs.c, and can ensure they always are.
src/ChangeLog addition:
2017-05-30 Aidan Kehoe <kehoea(a)parhasard.net>
* emacs.c (vars_of_emacs):
If there's no associated #define, initialise xemacs-extra-name to
nil.
Affected #: 4 files
diff -r 5465cf0baa425adc8df3c11e14f9c3783c6bc702 -r b803128e420963ce405b3ac51c7f9a80183c496b lisp/ChangeLog
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2017-05-30 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * about.el (about-xemacs):
+ Correct a recently-introduced bug here, give the correct bounding
+ keywords to #'parse-integer when working out the month of the
+ release date.
+ Don't check for xemacs-extra-name, xemacs-release-date being
+ #'boundp, we control src/emacs.c, and can ensure they always are.
+
2017-03-15 Aidan Kehoe <kehoea(a)parhasard.net>
* make-docfile.el:
diff -r 5465cf0baa425adc8df3c11e14f9c3783c6bc702 -r b803128e420963ce405b3ac51c7f9a80183c496b lisp/about.el
--- a/lisp/about.el
+++ b/lisp/about.el
@@ -380,23 +380,20 @@
emacs-major-version
emacs-minor-version))))
(emacs-release-date
- (if (and (boundp 'xemacs-release-date)
- (stringp xemacs-release-date)
- (string-match "^\\([0-9]\\{4\\}\\)-\\([0-9][0-9]\\)-"
- xemacs-release-date))
+ (if (string-match "^\\([0-9]\\{4\\}\\)-\\([0-9][0-9]\\)-"
+ xemacs-release-date)
(format "%s %s"
(aref [ "January" "February" "March" "April"
"May" "June" "July" "August"
"September" "October" "November" "December" ]
(1- (parse-integer xemacs-release-date
- :start (match-beginning 2))))
+ :start (match-beginning 2)
+ :end (match-end 2))))
(match-string 1 xemacs-release-date))
"February 2005 (defaulted in about.el)"))
- (emacs-variant-info (if (and xemacs-extra-name
- (stringp xemacs-extra-name)
- (< 0 (length xemacs-extra-name)))
- (format " %s" xemacs-extra-name)
- ""))
+ (emacs-variant-info (if (< 0 (length xemacs-extra-name))
+ (concat " " xemacs-extra-name)
+ ""))
(emacs-about-version (format "version %s of %s%s"
emacs-short-version
emacs-release-date
diff -r 5465cf0baa425adc8df3c11e14f9c3783c6bc702 -r b803128e420963ce405b3ac51c7f9a80183c496b src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-30 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * emacs.c (vars_of_emacs):
+ If there's no associated #define, initialise xemacs-extra-name to
+ nil.
+
2017-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
* editfns.c (Fencode_time):
diff -r 5465cf0baa425adc8df3c11e14f9c3783c6bc702 -r b803128e420963ce405b3ac51c7f9a80183c496b src/emacs.c
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -4392,6 +4392,8 @@
*/ );
#ifdef XEMACS_EXTRA_NAME
Vxemacs_extra_name = build_ascstring (XEMACS_EXTRA_NAME);
+#else
+ Vxemacs_extra_name = Qnil;
#endif
DEFVAR_LISP ("xemacs-release-date", &Vxemacs_release_date /*
Repository URL: https://bitbucket.org/xemacs/xemacs/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
commit/XEmacs: kehoea: Small fix, #'generate-new-buffer-name.
7 years, 6 months
Bitbucket
1 new commit in XEmacs:
https://bitbucket.org/xemacs/xemacs/commits/5465cf0baa42/
Changeset: 5465cf0baa42
User: kehoea
Date: 2017-05-17 22:27:34+00:00
Summary: Small fix, #'generate-new-buffer-name.
2017-05-17 Aidan Kehoe <kehoea(a)parhasard.net>
* buffer.c (Fgenerate_new_buffer_name):
Start the count here at <2> as documented, rather than 3.
Affected #: 2 files
diff -r d745116738120282e98054133b2835e04a206758 -r 5465cf0baa425adc8df3c11e14f9c3783c6bc702 src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -27,6 +27,11 @@
Accept a vector PACKAGE here too, thank you for the bug report,
Raymond Toy.
+2017-05-17 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * buffer.c (Fgenerate_new_buffer_name):
+ Start the count here at <2> as documented, rather than 3.
+
2017-04-19 Aidan Kehoe <kehoea(a)parhasard.net>
* buffer.c:
diff -r d745116738120282e98054133b2835e04a206758 -r 5465cf0baa425adc8df3c11e14f9c3783c6bc702 src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -814,7 +814,7 @@
+ sizeof ("<>");
candidate = alloca_ibytes (csize);
- count = itext_ichar_eql (XSTRING_DATA (name), ' ') ? get_random () : 2;
+ count = itext_ichar_eql (XSTRING_DATA (name), ' ') ? get_random () : 1;
while (1)
{
/* XEmacs; GNU worry about the performance of this function, and then
Repository URL: https://bitbucket.org/xemacs/xemacs/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
commit/cc-mode: acm: c-defun-name: Return fully qualified method
names when wanted in C++, etc.
7 years, 6 months
Bitbucket
1 new commit in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/8e6823f66785/
Changeset: 8e6823f66785
User: acm
Date: 2017-05-30 16:58:53+00:00
Summary: c-defun-name: Return fully qualified method names when wanted in C++, etc.
* cc-cmds.el (c-defun-name): Use c-back-over-compound-identifier in place of
c-backward-token-2 near the end of the function.
Affected #: 1 file
diff -r 2384e48be6208267c13505dffac6a0d98b7bc568 -r 8e6823f66785d1de8e3724962e8e23273be7cd42 cc-cmds.el
--- a/cc-cmds.el
+++ b/cc-cmds.el
@@ -1807,7 +1807,7 @@
(c-backward-token-2)
(c-backward-syntactic-ws))
(setq name-end (point))
- (c-backward-token-2)
+ (c-back-over-compound-identifier)
(buffer-substring-no-properties (point) name-end)))))))))
(defun c-declaration-limits (near)
Repository URL: https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
commit/cc-mode: acm: Correct earlier change: insert missing `and'
form in `c-forward-declarator'
7 years, 7 months
Bitbucket
1 new commit in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/2384e48be620/
Changeset: 2384e48be620
User: acm
Date: 2017-05-12 20:58:27+00:00
Summary: Correct earlier change: insert missing `and' form in `c-forward-declarator'
* cc-engine (c-forward-declarator): Insert missing `and' form inside a
`save-excursion'.
Affected #: 1 file
diff -r 51013c73b8b609aaf152a3462bd8630e84543a3d -r 2384e48be6208267c13505dffac6a0d98b7bc568 cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -8115,11 +8115,12 @@
(not
(and (c-major-mode-is 'c++-mode)
(save-excursion
- (c-go-up-list-backward)
- (eq (char-after) ?\()
- (progn (c-backward-syntactic-ws)
- (c-simple-skip-symbol-backward))
- (looking-at c-paren-stmt-key)))))))
+ (and
+ (c-go-up-list-backward)
+ (eq (char-after) ?\()
+ (progn (c-backward-syntactic-ws)
+ (c-simple-skip-symbol-backward))
+ (looking-at c-paren-stmt-key))))))))
found)
(eq (char-before) ?\[)
(c-go-up-list-forward))
Repository URL: https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
commit/cc-mode: acm: Fontify C++ for loop variable as variable,
even when followed by parentheses
7 years, 7 months
Bitbucket
1 new commit in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/51013c73b8b6/
Changeset: 51013c73b8b6
User: acm
Date: 2017-05-12 19:39:12+00:00
Summary: Fontify C++ for loop variable as variable, even when followed by parentheses
In the following: "for (auto *Friend : Class->friends()) {", "Friend" was
getting fontified as a function, due to insufficient checking of the tokens
between it and "()".
* cc-langs.el (c-:-op-cont-tokens, c-:-op-cont-regexp): New lang-consts/vars.
* cc-engine.el (c-forward-declarator): After finding a putative declarator's
identifier, check for a ":" token inside a for's parentheses, and abort the
search for "(" if this is found.
Affected #: 2 files
diff -r 598139a604f056a434e8953313b25270717d013d -r 51013c73b8b609aaf152a3462bd8630e84543a3d cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -8099,8 +8099,28 @@
;; initializing brace lists.
(let (found)
(while
- (and (setq found (c-syntactic-re-search-forward
- "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
+ (and (progn
+ ;; In the next loop, we keep searching forward whilst
+ ;; we find ":"s which aren't single colons inside C++
+ ;; "for" statements.
+ (while
+ (and
+ (setq found
+ (c-syntactic-re-search-forward
+ "[;:,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)"
+ limit t t))
+ (eq (char-before) ?:)
+ (if (looking-at c-:-op-cont-regexp)
+ (progn (goto-char (match-end 0)) t)
+ (not
+ (and (c-major-mode-is 'c++-mode)
+ (save-excursion
+ (c-go-up-list-backward)
+ (eq (char-after) ?\()
+ (progn (c-backward-syntactic-ws)
+ (c-simple-skip-symbol-backward))
+ (looking-at c-paren-stmt-key)))))))
+ found)
(eq (char-before) ?\[)
(c-go-up-list-forward))
(setq brackets-after-id t))
diff -r 598139a604f056a434e8953313b25270717d013d -r 51013c73b8b609aaf152a3462bd8630e84543a3d cc-langs.el
--- a/cc-langs.el
+++ b/cc-langs.el
@@ -1316,6 +1316,21 @@
(c-lang-defvar c-multichar->-op-not->>-regexp
(c-lang-const c-multichar->-op-not->>-regexp))
+(c-lang-defconst c-:-op-cont-tokens
+ ;; A list of second and subsequent characters of all multicharacter tokens
+ ;; that begin with ":".
+ t (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
+ t
+ "\\`:."
+ (lambda (op) (substring op 1))))
+
+(c-lang-defconst c-:-op-cont-regexp
+ ;; Regexp matching the second and subsequent characters of all
+ ;; multicharacter tokens that begin with ":".
+ t (c-make-keywords-re nil (c-lang-const c-:-op-cont-tokens)))
+(c-lang-defvar c-:-op-cont-regexp
+ (c-lang-const c-:-op-cont-regexp))
+
(c-lang-defconst c-stmt-delim-chars
;; The characters that should be considered to bound statements. To
;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to
Repository URL: https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
commit/XEmacs: 3 new changesets
7 years, 7 months
Bitbucket
3 new commits in XEmacs:
https://bitbucket.org/xemacs/xemacs/commits/a0268c5597f3/
Changeset: a0268c5597f3
User: kehoea
Date: 2017-05-11 07:13:08+00:00
Summary: Fix dummy chartab_range initializers.
Affected #: 3 files
diff -r eec2a31de9d67f78b606314136ed13abb364046d -r a0268c5597f37d95723b9570254be522f714986c src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2017-04-27 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * chartab.c (char_table_print_preprocess):
+ (char_table_nsubst_structures_descend):
+ data.c (build_fixnum_to_char_map):
+ Fix chartab_range initializers.
+
2017-04-21 Aidan Kehoe <kehoea(a)parhasard.net>
* elhash.c (intern_istring):
diff -r eec2a31de9d67f78b606314136ed13abb364046d -r a0268c5597f37d95723b9570254be522f714986c src/chartab.c
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -157,7 +157,7 @@
char_table_print_preprocess (Lisp_Object object, Lisp_Object print_number_table,
Elemcount *seen_object_count)
{
- struct chartab_range ctr = { CHARTAB_RANGE_ALL, 0, Qnil, 0 };
+ struct chartab_range ctr = { CHARTAB_RANGE_ALL, 0, 0, Qnil, 0 };
preprocess_info_t preprocess_info = { print_number_table, seen_object_count };
map_char_table (object, &ctr, print_preprocess_mapper, &preprocess_info);
}
@@ -193,7 +193,7 @@
Lisp_Object number_table,
Boolint test_not_unboundp)
{
- struct chartab_range ctr = { CHARTAB_RANGE_ALL, 0, Qnil, 0 };
+ struct chartab_range ctr = { CHARTAB_RANGE_ALL, 0, 0, Qnil, 0 };
nsubst_structures_info_t nsubst_structures_info
= { number_table, new_, old, object, test_not_unboundp };
diff -r eec2a31de9d67f78b606314136ed13abb364046d -r a0268c5597f37d95723b9570254be522f714986c src/data.c
--- a/src/data.c
+++ b/src/data.c
@@ -1504,7 +1504,7 @@
build_fixnum_to_char_map (Lisp_Object radix_table)
{
Lisp_Object highest_value, result;
- struct chartab_range ctr = { CHARTAB_RANGE_ALL, 0, Qnil, 0 };
+ struct chartab_range ctr = { CHARTAB_RANGE_ALL, 0, 0, Qnil, 0 };
Ichar *cctable;
EMACS_INT ii, cclen;
Ibyte *data;
https://bitbucket.org/xemacs/xemacs/commits/50b05df76160/
Changeset: 50b05df76160
User: kehoea
Date: 2017-05-11 18:58:56+00:00
Summary: Work around type +/- template problems on the C++ build, text.h
src/ChangeLog addition:
2017-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
* alloc.c (resize_string):
Use set_string_byte() here for the zero termination.
* text.h:
Make string_byte(), set_string_byte() into inline functions to
work around g++ type (+/- template) difficulties with the macro
versions.
Affected #: 3 files
diff -r a0268c5597f37d95723b9570254be522f714986c -r 50b05df76160d68a18c7afcaf4f66c0fb339dcbe src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2017-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * alloc.c (resize_string):
+ Use set_string_byte() here for the zero termination.
+ * text.h:
+ Make string_byte(), set_string_byte() into inline functions to
+ work around g++ type (+/- template) difficulties with the macro
+ versions.
+
2017-04-27 Stephen J. Turnbull <stephen(a)xemacs.org>
* chartab.c (char_table_print_preprocess):
diff -r a0268c5597f37d95723b9570254be522f714986c -r 50b05df76160d68a18c7afcaf4f66c0fb339dcbe src/alloc.c
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3143,7 +3143,7 @@
XSET_STRING_LENGTH (s, XSTRING_LENGTH (s) + delta);
/* If pos < 0, the string won't be zero-terminated.
Terminate now just to make sure. */
- XSTRING_DATA (s)[XSTRING_LENGTH (s)] = '\0';
+ set_string_byte (s, XSTRING_LENGTH (s), '\0');
if (pos >= 0)
/* We also have to adjust all of the extent indices after the
diff -r a0268c5597f37d95723b9570254be522f714986c -r 50b05df76160d68a18c7afcaf4f66c0fb339dcbe src/text.h
--- a/src/text.h
+++ b/src/text.h
@@ -1935,11 +1935,24 @@
#define string_char_length(s) \
string_index_byte_to_char (s, XSTRING_LENGTH (s))
-/* Without the cast, C++ promotes the following expression to an int and then
- complains about a narrowing cast when it is used as an Ibyte. */
-#define string_byte(s, i) (Ibyte) (XSTRING_DATA (s)[i] + 0)
+
+DECLARE_INLINE_HEADER (
+Ibyte
+string_byte (Lisp_Object s, Bytecount i)
+)
+{
+ /* C++ deals with a macro version of this badly. */
+ return XSTRING_DATA (s)[i];
+}
/* In case we ever allow strings to be in a different format ... */
-#define set_string_byte(s, i, c) (XSTRING_DATA (s)[i] = (c))
+DECLARE_INLINE_HEADER (
+Ibyte
+set_string_byte(Lisp_Object s, Bytecount i, Ibyte c)
+)
+{
+ /* See above re C++. */
+ return XSTRING_DATA (s)[i] = (c);
+}
#define ASSERT_VALID_CHAR_STRING_INDEX_UNSAFE(s, x) do { \
text_checking_assert ((x) >= 0 && x <= string_char_length (s)); \
https://bitbucket.org/xemacs/xemacs/commits/d74511673812/
Changeset: d74511673812
User: kehoea
Date: 2017-05-11 20:02:50+00:00
Summary: Restrict the integer values passed as the ZONE argument, #'encode-time
src/ChangeLog addition:
2017-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
* editfns.c (Fencode_time):
Restrict the possible integer values passed as the ZONE argument
to this function, as per the OS X and Linux documentation for
tzset(3).
tests/ChangeLog addition:
2017-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/os-tests.el:
Test restrictions just introduced to the integer values passed as
the ZONE argument to #'encode-time.
Affected #: 4 files
diff -r 50b05df76160d68a18c7afcaf4f66c0fb339dcbe -r d745116738120282e98054133b2835e04a206758 src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2017-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * editfns.c (Fencode_time):
+ Restrict the possible integer values passed as the ZONE argument
+ to this function, as per the OS X and Linux documentation for
+ tzset(3).
+
2017-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
* alloc.c (resize_string):
diff -r 50b05df76160d68a18c7afcaf4f66c0fb339dcbe -r d745116738120282e98054133b2835e04a206758 src/editfns.c
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1230,24 +1230,40 @@
/* #### This business of modifying environ is horrendous!
Why don't we just putenv()? Why don't we implement our own
funs that don't require this futzing? */
- Extbyte tzbuf[100];
+ Ibyte tzbuf[100];
Extbyte *tzstring;
Extbyte **oldenv = environ, **newenv;
if (STRINGP (zone))
tzstring = LISP_STRING_TO_EXTERNAL (zone, Qtime_zone_encoding);
- else if (FIXNUMP (zone))
+ else if (INTEGERP (zone))
{
- int abszone = abs (XFIXNUM (zone));
- /* We specify the time zone in offset notation (see `man
- tzset' for details). The offset indicates the value one
- must add to local time to arrive at UTC. Thus, we sign
- the offset with a `-' if the time zone is east of GMT; we
- sign the offset with a `+' if the time zone is GMT (then
- the offset is 0) or if the time zone is west of GMT. */
- sprintf (tzbuf, "XXX%s%d:%02d:%02d", (XFIXNUM (zone) < 0) ? "+" : "-",
- abszone / (60*60), (abszone/60) % 60, abszone % 60);
- tzstring = tzbuf;
+ int abszone;
+ Bytecount bufwritten;
+
+ /* The number of hours must be less or equal to 24, documented as
+ such on OS X and Linux as of 2017. */
+ check_integer_range (zone, make_fixnum (-86400),
+ make_fixnum (86400));
+
+ abszone = abs ((int) (XFIXNUM (zone)));
+
+ /* We specify the time zone in offset notation (see `man tzset' for
+ details). The offset indicates the value one must add to local
+ time to arrive at UTC; the Emacs sign convention is the opposite
+ of that used by tzset(3).
+
+ Thus, we sign the offset with a `-' if the time zone is east of
+ GMT; we sign the offset with a `+' if the time zone is GMT (then
+ the offset is 0) or if the time zone is west of GMT. */
+ bufwritten
+ = emacs_snprintf (tzbuf, sizeof (tzbuf), "XXX%s%d:%02d:%02d",
+ XFIXNUM (zone) <= 0 ? "+" : "-",
+ abszone / (60*60),
+ (abszone/60) % 60,
+ abszone % 60);
+ assert (bufwritten < (Bytecount) (sizeof (tzbuf)));
+ tzstring = (Extbyte *) tzbuf;
}
else
invalid_argument ("Invalid time zone specification", Qunbound);
diff -r 50b05df76160d68a18c7afcaf4f66c0fb339dcbe -r d745116738120282e98054133b2835e04a206758 tests/ChangeLog
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * automated/os-tests.el:
+ Test restrictions just introduced to the integer values passed as
+ the ZONE argument to #'encode-time.
+
2017-03-16 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/lisp-reader-tests.el (args-out-of-range):
diff -r 50b05df76160d68a18c7afcaf4f66c0fb339dcbe -r d745116738120282e98054133b2835e04a206758 tests/automated/os-tests.el
--- a/tests/automated/os-tests.el
+++ b/tests/automated/os-tests.el
@@ -123,4 +123,13 @@
do
(Assert (string= post (substitute-in-file-name pre))))
+;; Check some restrictions introduced to the ZONE argument to #'encode-time.
+
+(Check-Error (encode-time 24 4 20 11 5 2017 -86401) args-out-of-range)
+(Assert (equal (encode-time 24 4 20 11 5 2017 -86400)
+ '(22806 . 5448))) ;; "05/12/17 09:04:25 PM"
+(Assert (equal (encode-time 24 4 20 11 5 2017 86400)
+ '(22803 . 29256))) ;; "05/10/17 09:04:24 PM"
+(Check-Error (encode-time 24 4 20 11 5 2017 86401) args-out-of-range)
+
;;; end of os-tests.el
Repository URL: https://bitbucket.org/xemacs/xemacs/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
commit/cc-mode: acm: CC Mode internal cache: Handle a cache pos being
inside a two-char construct.
7 years, 7 months
Bitbucket
1 new commit in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/598139a604f0/
Changeset: 598139a604f0
User: acm
Date: 2017-05-07 09:03:21+00:00
Summary: CC Mode internal cache: Handle a cache pos being inside a two-char construct.
Cache c-state-semi-nonlit-pos-cache was failing when a cache position was,
e.g., between the two characters of an opening comment "/*", and additionally
there were an odd number of quote marks (apostrophes) in the comment. This
happened in .../src/xdisp.c in the Emacs master branch around 2017-05-02 at
buffer position 615001.
* cc-defs.el (c-emacs-features): Repurpose symbol pps-extended-state to mean
that there are at least 11 elements in the parser state.
* cc-engine.el (c-cache-to-parse-ps-state, c-parse-ps-state-to-cache): Rewrite
these to use enhanced cache element list types which indicate potentially
being inside two-char constructs.
(c-parse-ps-state-below): Rewrite to use the new versions of the above two
functions.
Affected #: 2 files
diff -r 42d965b3e8913f32d004a9cb170cf27ade0fb08f -r 598139a604f056a434e8953313b25270717d013d cc-defs.el
--- a/cc-defs.el
+++ b/cc-defs.el
@@ -1937,14 +1937,18 @@
(setq list (cons 'add-hook-local list)))
- ;; See if `parse-partial-sexp' returns the eighth element.
- (if (c-safe (>= (length (save-excursion
- (parse-partial-sexp (point) (point))))
- 10))
- (setq list (cons 'pps-extended-state list))
- (error (concat
- "CC Mode is incompatible with this version of Emacs - "
- "`parse-partial-sexp' has to return at least 10 elements.")))
+ ;; Check how many elements `parse-partial-sexp' returns.
+ (let ((ppss-size (or (c-safe (length
+ (save-excursion
+ (parse-partial-sexp (point) (point)))))
+ 0)))
+ (cond
+ ((>= ppss-size 11) (setq list (cons 'pps-extended-state list)))
+ ((>= ppss-size 10))
+ (t (error
+ (concat
+ "CC Mode is incompatible with this version of Emacs - "
+ "`parse-partial-sexp' has to return at least 10 elements.")))))
;;(message "c-emacs-features: %S" list)
list)
@@ -1967,10 +1971,9 @@
(i.e. the syntax class `!').
'gen-string-delim Generic string delimiters work
(i.e. the syntax class `|').
-'pps-extended-state `parse-partial-sexp' returns a list with at least 10
- elements, i.e. it contains the position of the start of
- the last comment or string. It's always set - CC Mode
- no longer works in emacsen without this feature.
+'pps-extended-state `parse-partial-sexp' returns a list with at least 11
+ elements, i.e. it indicates having stopped after the
+ first character of a potential two-char construct.
'posix-char-classes The regexp engine understands POSIX character classes.
'col-0-paren It's possible to turn off the ad-hoc rule that a paren
in column zero is the start of a defun.
diff -r 42d965b3e8913f32d004a9cb170cf27ade0fb08f -r 598139a604f056a434e8953313b25270717d013d cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -2578,17 +2578,24 @@
(defun c-cache-to-parse-ps-state (elt)
;; Create a list suitable to use as the old-state parameter to
- ;; `parse-partial-sexp', out of ELT. ELT is either just a number, a buffer
- ;; position, or it is a list (POS TYPE STARTING-POS). Here POS is the
- ;; buffer position the other elements are pertinent for, TYPE is either 'c
- ;; or 'c++ (for a comment) or a character (for a string delimiter) or t
- ;; (meaning a string fence opened the string), STARTING-POS is the starting
- ;; position of the comment or string.
- (if (consp elt)
+ ;; `parse-partial-sexp', out of ELT, a member of
+ ;; `c-state-semi-nonlit-pos-cache'. ELT is either just a number, or a list
+ ;; with 2, 3, or 4 members (See `c-parse-ps-state-to-cache'). That number
+ ;; or the car of the list is the "position element" of ELT, the position
+ ;; where ELT is valid.
+ ;;
+ ;; POINT is left at the postition for which the returned state is valid. It
+ ;; will be either the position element of ELT, or one character before
+ ;; that. (The latter happens in Emacs <= 25 and XEmacs, when ELT indicates
+ ;; its position element directly follows a potential first character of a
+ ;; two char construct (such as a comment opener or an escaped character).)
+ (if (and (consp elt) (>= (length elt) 3))
+ ;; Inside a string or comment
(let ((depth 0) (containing nil) (last nil)
in-string in-comment (after-quote nil)
(min-depth 0) com-style com-str-start (intermediate nil)
- (between-syntax nil)
+ (char-1 (nth 3 elt)) ; first char of poss. 2-char construct
+ (pos (car elt))
(type (cadr elt)))
(setq com-str-start (car (cddr elt)))
(cond
@@ -2599,28 +2606,88 @@
com-style (if (eq type 'c++) 1 nil)))
(t (c-benign-error "Invalid type %s in c-cache-to-parse-ps-state"
elt)))
- (list depth containing last
- in-string in-comment after-quote
- min-depth com-style com-str-start
- intermediate nil))
- (copy-tree '(0 nil nil nil nil nil 0 nil nil nil nil))))
+ (if (memq 'pps-extended-state c-emacs-features)
+ (progn
+ (goto-char pos)
+ (list depth containing last
+ in-string in-comment after-quote
+ min-depth com-style com-str-start
+ intermediate char-1))
+ (goto-char (if char-1
+ (1- pos)
+ pos))
+ (list depth containing last
+ in-string in-comment nil
+ min-depth com-style com-str-start
+ intermediate)))
+
+ ;; Not in a string or comment.
+ (if (memq 'pps-extended-state c-emacs-features)
+ (progn
+ (goto-char (if (consp elt) (car elt) elt))
+ (list 0 nil nil nil nil
+ (and (consp elt) (eq (nth 1 elt) 9)) ; 9 is syntax code for "escape".
+ 0 nil nil nil
+ (and (consp elt) (nth 1 elt))))
+ (goto-char (if (consp elt) (car elt) elt))
+ (if (and (consp elt) (cdr elt)) (backward-char))
+ (copy-tree '(0 nil nil nil nil
+ nil
+ 0 nil nil nil)))))
(defun c-parse-ps-state-to-cache (state)
;; Convert STATE, a `parse-partial-sexp' state valid at POINT, to an element
- ;; for the `c-state-semi-nonlit-pos-cache' cache. This is either POINT
- ;; (when point is not in a literal) or a list (POINT TYPE STARTING-POS),
- ;; where TYPE is the type of the literal, either 'string, 'c, or 'c++, and
- ;; STARTING-POS is the starting position of the comment or string.
- (cond
- ((nth 3 state) ; A string
- (list (point) (nth 3 state) (nth 8 state)))
- ((and (nth 4 state) ; A comment
- (not (eq (nth 7 state) 'syntax-table))) ; but not a psuedo comment.
- (list (point)
- (if (eq (nth 7 state) 1) 'c++ 'c)
- (nth 8 state)))
- (t ; Neither string nor comment.
- (point))))
+ ;; for the `c-state-semi-nonlit-pos-cache' cache. This is one of
+ ;; o - POINT (when point is not in a literal);
+ ;; o - (POINT CHAR-1) (when the last character before point is potentially
+ ;; the first of a two-character construct
+ ;; o - (POINT TYPE STARTING-POS) (when in a literal);
+ ;; o - (POINT TYPE STARTING-POS CHAR-1) (Combination of the previous two),
+ ;; where TYPE is the type of the literal (either 'c, or 'c++, or the
+ ;; character which closes the string), STARTING-POS is the starting
+ ;; position of the comment or string. CHAR-1 is either the character
+ ;; potentially forming the first half of a two-char construct (in Emacs <=
+ ;; 25 and XEmacs) or the syntax of the character (in Emacs >= 26).
+ (if (memq 'pps-extended-state c-emacs-features)
+ ;; Emacs >= 26.
+ (let ((basic
+ (cond
+ ((nth 3 state) ; A string
+ (list (point) (nth 3 state) (nth 8 state)))
+ ((and (nth 4 state) ; A comment
+ (not (eq (nth 7 state) 'syntax-table))) ; but not a psuedo comment.
+ (list (point)
+ (if (eq (nth 7 state) 1) 'c++ 'c)
+ (nth 8 state)))
+ (t ; Neither string nor comment.
+ (point)))))
+ (if (nth 10 state)
+ (append (if (consp basic)
+ basic
+ (list basic))
+ (list (nth 10 state)))
+ basic))
+
+ ;; Emacs <= 25, XEmacs.
+ (cond
+ ((nth 3 state) ; A string
+ (if (eq (char-before) ?\\)
+ (list (point) (nth 3 state) (nth 8 state) ?\\)
+ (list (point) (nth 3 state) (nth 8 state))))
+ ((and (nth 4 state) ; comment
+ (not (eq (nth 7 state) 'syntax-table)))
+ (if (and (eq (char-before) ?*)
+ (> (- (point) (nth 8 state)) 2)) ; not "/*/".
+ (list (point)
+ (if (eq (nth 7 state) 1) 'c++ 'c)
+ (nth 8 state)
+ ?*)
+ (list (point)
+ (if (eq (nth 7 state) 1) 'c++ 'c)
+ (nth 8 state))))
+ (t (if (memq (char-before) '(?/ ?\\))
+ (list (point) (char-before))
+ (point))))))
(defsubst c-ps-state-cache-pos (elt)
;; Get the buffer position from ELT, an element from the cache
@@ -2640,7 +2707,7 @@
(save-restriction
(widen)
(let ((c c-state-semi-nonlit-pos-cache)
- elt state pos npos high-elt)
+ elt state npos high-elt)
;; Trim the cache to take account of buffer changes.
(while (and c (> (c-ps-state-cache-pos (car c))
c-state-semi-nonlit-pos-cache-limit))
@@ -2650,29 +2717,27 @@
(while (and c (> (c-ps-state-cache-pos (car c)) here))
(setq high-elt (car c))
(setq c (cdr c)))
- (setq pos (or (and c (c-ps-state-cache-pos (car c)))
- (point-min)))
-
- (if high-elt
- (setq state (c-cache-to-parse-ps-state (car c)))
- (setq elt (if c (car c) (point-min)))
- (setq state
- (if c
- (c-cache-to-parse-ps-state (car c))
- (copy-tree '(0 nil nil nil nil nil 0 nil nil nil nil))))
+ (goto-char (or (and c (c-ps-state-cache-pos (car c)))
+ (point-min)))
+ (setq state
+ (if c
+ (c-cache-to-parse-ps-state (car c))
+ (copy-tree '(0 nil nil nil nil nil 0 nil nil nil nil))))
+
+ (when (not high-elt)
+ ;; We need to extend the cache. Add an element to
+ ;; `c-state-semi-nonlit-pos-cache' each iteration of the following.
(while
- ;; Add an element to `c-state-semi-nonlit-pos-cache' each iteration.
- (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here)
- (setq state (parse-partial-sexp pos npos nil nil state))
+ (<= (setq npos (+ (point) c-state-nonlit-pos-interval)) here)
+ (setq state (parse-partial-sexp (point) npos nil nil state))
(setq elt (c-parse-ps-state-to-cache state))
(setq c-state-semi-nonlit-pos-cache
- (cons elt c-state-semi-nonlit-pos-cache))
- (setq pos npos)))
-
- (if (> pos c-state-semi-nonlit-pos-cache-limit)
- (setq c-state-semi-nonlit-pos-cache-limit pos))
-
- (cons pos state)))))
+ (cons elt c-state-semi-nonlit-pos-cache))))
+
+ (if (> (point) c-state-semi-nonlit-pos-cache-limit)
+ (setq c-state-semi-nonlit-pos-cache-limit (point)))
+
+ (cons (point) state)))))
(defun c-state-safe-place (here)
;; Return a buffer position before HERE which is "safe", i.e. outside any
Repository URL: https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.