[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ mode and c-beginning-of-current-token

From: Stefan Monnier
Subject: Re: C++ mode and c-beginning-of-current-token
Date: Thu, 17 May 2007 10:32:38 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (gnu/linux)

> Can I ask a silly question, too?  There are two "calling"s of
> UPDATE_SYNTAX_TABLE_BACKWARD in `skip_chars', one with the "argument"
> (pos), the other with (pos - 1).  To me, the second one does not look
> like a typo, but a correct piece of code on purpose.  Yes, changing it
> from (pos - 1) to (pos) works, but it seems to be dangerous to me.

The important part is to make sure that the syntax-table is up-to-date for
the char being read, when to char is passed to `SYNTAX'.

Also, it is important to update the syntax-table only after making sure that
the new position is valid.  So I believe the patch below is what we want.


--- orig/src/syntax.c
+++ mod/src/syntax.c
@@ -1691,10 +1691,10 @@
                      p = GPT_ADDR;
                      stop = endp;
+                 UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1);
                  if (! fastmap[(int) SYNTAX (p[-1])])
                  p--, pos--;
-                 UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]