+/* Set the syntax entry VAL for char C in table TABLE. */
+
+static void
+SET_RAW_SYNTAX_ENTRY (Lisp_Object table, int c, Lisp_Object val)
+{
+ CHAR_TABLE_SET (table, c, val);
+}
+
+/* Set the syntax entry VAL for char-range RANGE in table TABLE.
+ RANGE is a cons (FROM . TO) specifying the range of characters. */
+
+static void
+SET_RAW_SYNTAX_ENTRY_RANGE (Lisp_Object table, Lisp_Object range,
+ Lisp_Object val)
+{
+ Fset_char_table_range (table, range, val);
+}
+
+/* Extract the information from the entry for character C
+ in the current syntax table. */
+
+static Lisp_Object
+SYNTAX_MATCH (int c)
+{
+ Lisp_Object ent = SYNTAX_ENTRY (c);
+ return CONSP (ent) ? XCDR (ent) : Qnil;
+}
+
+/* This should be called with FROM at the start of forward
+ search, or after the last position of the backward search. It
+ makes sure that the first char is picked up with correct table, so
+ one does not need to call UPDATE_SYNTAX_TABLE immediately after the
+ call.
+ Sign of COUNT gives the direction of the search.
+ */
+
+static void
+SETUP_SYNTAX_TABLE (ptrdiff_t from, ptrdiff_t count)
+{
+ SETUP_BUFFER_SYNTAX_TABLE ();
+ gl_state.b_property = BEGV;
+ gl_state.e_property = ZV + 1;
+ gl_state.object = Qnil;
+ gl_state.offset = 0;
+ if (parse_sexp_lookup_properties)
+ if (count > 0 || from > BEGV)
+ update_syntax_table (count > 0 ? from : from - 1, count, 1, Qnil);
+}
+
+/* Same as above, but in OBJECT. If OBJECT is nil, use current buffer.
+ If it is t (which is only used in fast_c_string_match_ignore_case),
+ ignore properties altogether.
+
+ This is meant for regex.c to use. For buffers, regex.c passes arguments
+ to the UPDATE_SYNTAX_TABLE functions which are relative to BEGV.
+ So if it is a buffer, we set the offset field to BEGV. */
+
+void
+SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object,
+ ptrdiff_t from, ptrdiff_t count)
+{
+ SETUP_BUFFER_SYNTAX_TABLE ();
+ gl_state.object = object;
+ if (BUFFERP (gl_state.object))
+ {
+ struct buffer *buf = XBUFFER (gl_state.object);
+ gl_state.b_property = 1;
+ gl_state.e_property = BUF_ZV (buf) - BUF_BEGV (buf) + 1;
+ gl_state.offset = BUF_BEGV (buf) - 1;
+ }
+ else if (NILP (gl_state.object))
+ {
+ gl_state.b_property = 1;
+ gl_state.e_property = ZV - BEGV + 1;
+ gl_state.offset = BEGV - 1;
+ }
+ else if (EQ (gl_state.object, Qt))
+ {
+ gl_state.b_property = 0;
+ gl_state.e_property = PTRDIFF_MAX;
+ gl_state.offset = 0;
+ }
+ else
+ {
+ gl_state.b_property = 0;
+ gl_state.e_property = 1 + SCHARS (gl_state.object);
+ gl_state.offset = 0;
+ }
+ if (parse_sexp_lookup_properties)
+ update_syntax_table (from + gl_state.offset - (count <= 0),
+ count, 1, gl_state.object);
+}
+