-/* Make syntax table state (gl_state) good for POS, assuming it is
- currently good for a position before POS. */
-
-#define UPDATE_SYNTAX_TABLE_FORWARD(pos) \
- ((pos) >= gl_state.e_property - gl_state.offset \
- ? (update_syntax_table ((pos) + gl_state.offset, 1, 0, Qnil), 1) : 0)
-
-/* Make syntax table state (gl_state) good for POS, assuming it is
- currently good for a position after POS. */
-
-#define UPDATE_SYNTAX_TABLE_BACKWARD(pos) \
- ((pos) <= gl_state.b_property - gl_state.offset \
- ? (update_syntax_table ((pos) + gl_state.offset, -1, 0, Qnil), 1) : 0)
-
-/* Make syntax table good for POS. */
-
-#define UPDATE_SYNTAX_TABLE(pos) \
- ((pos) <= gl_state.b_property - gl_state.offset \
- ? (update_syntax_table ((pos) + gl_state.offset, -1, 0, Qnil), 1) \
- : ((pos) >= gl_state.e_property - gl_state.offset \
- ? (update_syntax_table ((pos) + gl_state.offset, 1, 0, Qnil), 1) : 0))
+/* Convert the byte offset BYTEPOS into a character position,
+ for the object recorded in gl_state with SETUP_SYNTAX_TABLE_FOR_OBJECT.
+
+ The value is meant for use in the UPDATE_SYNTAX_TABLE... macros.
+ These macros do nothing when parse_sexp_lookup_properties is 0,
+ so we return 0 in that case, for speed. */
+
+#define SYNTAX_TABLE_BYTE_TO_CHAR(bytepos) \
+ (! parse_sexp_lookup_properties \
+ ? 0 \
+ : STRINGP (gl_state.object) \
+ ? string_byte_to_char (gl_state.object, (bytepos)) \
+ : BUFFERP (gl_state.object) \
+ ? buf_bytepos_to_charpos (XBUFFER (gl_state.object), \
+ (bytepos) + BUF_BEGV_BYTE (XBUFFER (gl_state.object)) - 1) - BUF_BEGV (XBUFFER (gl_state.object)) + 1 \
+ : NILP (gl_state.object) \
+ ? BYTE_TO_CHAR ((bytepos) + BEGV_BYTE - 1) - BEGV + 1 \
+ : (bytepos))
+
+/* Make syntax table state (gl_state) good for CHARPOS, assuming it is
+ currently good for a position before CHARPOS. */
+
+#define UPDATE_SYNTAX_TABLE_FORWARD(charpos) \
+ (parse_sexp_lookup_properties \
+ && (charpos) >= gl_state.e_property \
+ ? (update_syntax_table ((charpos) + gl_state.offset, 1, 0, \
+ gl_state.object), \
+ 1) \
+ : 0)
+
+/* Make syntax table state (gl_state) good for CHARPOS, assuming it is
+ currently good for a position after CHARPOS. */
+
+#define UPDATE_SYNTAX_TABLE_BACKWARD(charpos) \
+ (parse_sexp_lookup_properties \
+ && (charpos) < gl_state.b_property \
+ ? (update_syntax_table ((charpos) + gl_state.offset, -1, 0, \
+ gl_state.object), \
+ 1) \
+ : 0)
+
+/* Make syntax table good for CHARPOS. */
+
+#define UPDATE_SYNTAX_TABLE(charpos) \
+ (parse_sexp_lookup_properties \
+ && (charpos) < gl_state.b_property \
+ ? (update_syntax_table ((charpos) + gl_state.offset, -1, 0, \
+ gl_state.object), \
+ 1) \
+ : (parse_sexp_lookup_properties \
+ && (charpos) >= gl_state.e_property \
+ ? (update_syntax_table ((charpos) + gl_state.offset, 1, 0,\
+ gl_state.object), \
+ 1) \
+ : 0))