Merge from emacs-24; up to 2012-12-27T08:21:08Z!rgm@gnu.org
[bpt/emacs.git] / src / syntax.c
index 6febcd2..390d732 100644 (file)
@@ -121,6 +121,7 @@ struct lisp_parse_state
     /* Char number of start of containing expression */
     ptrdiff_t prevlevelstart;
     ptrdiff_t location;             /* Char number at which parsing stopped.  */
+    ptrdiff_t location_byte; /* Corresponding byte position.  */
     ptrdiff_t comstr_start;  /* Position of last comment/string starter.  */
     Lisp_Object levelstarts; /* Char numbers of starts-of-expression
                                of levels (starting from outermost).  */
@@ -3277,6 +3278,7 @@ do { prev_from = from;                            \
 
  stop:   /* Here if stopping before start of sexp. */
   from = prev_from;    /* We have just fetched the char that starts it; */
+  from_byte = prev_from_byte;
   goto done; /* but return the position before it. */
 
  endquoted:
@@ -3288,6 +3290,7 @@ do { prev_from = from;                            \
   state.prevlevelstart
     = (curlevel == levelstart) ? -1 : (curlevel - 1)->last;
   state.location = from;
+  state.location_byte = from_byte;
   state.levelstarts = Qnil;
   while (curlevel > levelstart)
     state.levelstarts = Fcons (make_number ((--curlevel)->last),
@@ -3327,7 +3330,8 @@ Fifth arg OLDSTATE is a list like what this function returns.
 Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.
  If it is symbol `syntax-table', stop after the start of a comment or a
  string, or after end of a comment or a string.  */)
-  (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth, Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop)
+  (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth,
+   Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop)
 {
   struct lisp_parse_state state;
   EMACS_INT target;
@@ -3347,7 +3351,7 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.
                      (NILP (commentstop)
                       ? 0 : (EQ (commentstop, Qsyntax_table) ? -1 : 1)));
 
-  SET_PT (state.location);
+  SET_PT_BOTH (state.location, state.location_byte);
 
   return Fcons (make_number (state.depth),
           Fcons (state.prevlevelstart < 0