/* GNU Emacs routines to deal with syntax tables; also word and list parsing.
- Copyright (C) 1985, 1987, 1993, 1994, 1995, 1997, 1998, 1999, 2001,
- 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2011
Free Software Foundation, Inc.
This file is part of GNU Emacs.
Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error;
-int words_include_escapes;
-int parse_sexp_lookup_properties;
-
-/* Nonzero means `scan-sexps' treat all multibyte characters as symbol. */
-int multibyte_syntax_as_symbol;
-
/* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h,
if not compiled with GCC. No need to mark it, since it is used
only very temporarily. */
Lisp_Object syntax_temp;
-/* Non-zero means an open parenthesis in column 0 is always considered
- to be the start of a defun. Zero means an open parenthesis in
- column 0 has no special meaning. */
-
-int open_paren_in_column_0_is_defun_start;
-
/* This is the internal form of the parse state used in parse-partial-sexp. */
struct lisp_parse_state
struct gl_state_s gl_state; /* Global state of syntax parser. */
-INTERVAL interval_of (int, Lisp_Object);
#define INTERVALS_AT_ONCE 10 /* 1 + max-number of intervals
to scan to property-change. */
start/end of OBJECT. */
void
-update_syntax_table (int charpos, int count, int init, Lisp_Object object)
+update_syntax_table (EMACS_INT charpos, int count, int init,
+ Lisp_Object object)
{
Lisp_Object tmp_table;
int cnt = 0, invalidate = 1;
else
{
gl_state.use_global = 0;
- gl_state.current_syntax_table = current_buffer->syntax_table;
+ gl_state.current_syntax_table = BVAR (current_buffer, syntax_table);
}
}
return quoted;
}
-/* Return the bytepos one character after BYTEPOS.
- We assume that BYTEPOS is not at the end of the buffer. */
-
-INLINE EMACS_INT
-inc_bytepos (EMACS_INT bytepos)
-{
- if (NILP (current_buffer->enable_multibyte_characters))
- return bytepos + 1;
-
- INC_POS (bytepos);
- return bytepos;
-}
-
/* Return the bytepos one character before BYTEPOS.
We assume that BYTEPOS is not at the start of the buffer. */
-INLINE EMACS_INT
+static INLINE EMACS_INT
dec_bytepos (EMACS_INT bytepos)
{
- if (NILP (current_buffer->enable_multibyte_characters))
+ if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
return bytepos - 1;
DEC_POS (bytepos);
/* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */
static int
-prev_char_comend_first (int pos, int pos_byte)
+prev_char_comend_first (EMACS_INT pos, EMACS_INT pos_byte)
{
int c, val;
that determines quote parity to the comment-end. */
while (from != stop)
{
- int temp_byte, prev_syntax;
- int com2start, com2end;
+ EMACS_INT temp_byte;
+ int prev_syntax, com2start, com2end;
int comstart;
/* Move back and examine a character. */
have %..\n and %{..}%. */
if (from > stop && (com2end || comstart))
{
- int next = from, next_byte = from_byte, next_c, next_syntax;
+ EMACS_INT next = from, next_byte = from_byte;
+ int next_c, next_syntax;
DEC_BOTH (next, next_byte);
UPDATE_SYNTAX_TABLE_BACKWARD (next);
next_c = FETCH_CHAR_AS_MULTIBYTE (next_byte);
This is the one specified by the current buffer. */)
(void)
{
- return current_buffer->syntax_table;
+ return BVAR (current_buffer, syntax_table);
}
DEFUN ("standard-syntax-table", Fstandard_syntax_table,
{
int idx;
check_syntax_table (table);
- current_buffer->syntax_table = table;
+ BVAR (current_buffer, syntax_table) = table;
/* Indicate that this buffer now has a specified syntax table. */
idx = PER_BUFFER_VAR_IDX (syntax_table);
SET_PER_BUFFER_VALUE_P (current_buffer, idx, 1);
CHECK_CHARACTER (c);
if (NILP (syntax_table))
- syntax_table = current_buffer->syntax_table;
+ syntax_table = BVAR (current_buffer, syntax_table);
else
check_syntax_table (syntax_table);
return syntax;
}
\f
-int parse_sexp_ignore_comments;
-
-/* Char-table of functions that find the next or previous word
- boundary. */
-Lisp_Object Vfind_word_boundary_function_table;
-
/* Return the position across COUNT words from FROM.
If that many words cannot be found before the end of the buffer, return 0.
COUNT negative means scan backward and stop at word beginning. */
-int
-scan_words (register int from, register int count)
+EMACS_INT
+scan_words (register EMACS_INT from, register EMACS_INT count)
{
- register int beg = BEGV;
- register int end = ZV;
- register int from_byte = CHAR_TO_BYTE (from);
+ register EMACS_INT beg = BEGV;
+ register EMACS_INT end = ZV;
+ register EMACS_INT from_byte = CHAR_TO_BYTE (from);
register enum syntaxcode code;
int ch0, ch1;
Lisp_Object func, script, pos;
int *char_ranges;
int n_char_ranges = 0;
int negate = 0;
- register int i, i_byte;
+ register EMACS_INT i, i_byte;
/* Set to 1 if the current buffer is multibyte and the region
contains non-ASCII chars. */
int multibyte;
/* Set to 1 if STRING is multibyte and it contains non-ASCII
chars. */
int string_multibyte;
- int size_byte;
+ EMACS_INT size_byte;
const unsigned char *str;
int len;
Lisp_Object iso_classes;
if (XINT (lim) < BEGV)
XSETFASTINT (lim, BEGV);
- multibyte = (!NILP (current_buffer->enable_multibyte_characters)
+ multibyte = (!NILP (BVAR (current_buffer, enable_multibyte_characters))
&& (XINT (lim) - PT != CHAR_TO_BYTE (XINT (lim)) - PT_BYTE));
string_multibyte = SBYTES (string) > SCHARS (string);
}
{
- int start_point = PT;
- int pos = PT;
- int pos_byte = PT_BYTE;
+ EMACS_INT start_point = PT;
+ EMACS_INT pos = PT;
+ EMACS_INT pos_byte = PT_BYTE;
unsigned char *p = PT_ADDR, *endp, *stop;
if (forwardp)
register unsigned int c;
unsigned char fastmap[0400];
int negate = 0;
- register int i, i_byte;
+ register EMACS_INT i, i_byte;
int multibyte;
- int size_byte;
+ EMACS_INT size_byte;
unsigned char *str;
CHECK_STRING (string);
if (forwardp ? (PT >= XFASTINT (lim)) : (PT <= XFASTINT (lim)))
return make_number (0);
- multibyte = (!NILP (current_buffer->enable_multibyte_characters)
+ multibyte = (!NILP (BVAR (current_buffer, enable_multibyte_characters))
&& (XINT (lim) - PT != CHAR_TO_BYTE (XINT (lim)) - PT_BYTE));
memset (fastmap, 0, sizeof fastmap);
fastmap[i] ^= 1;
{
- int start_point = PT;
- int pos = PT;
- int pos_byte = PT_BYTE;
+ EMACS_INT start_point = PT;
+ EMACS_INT pos = PT;
+ EMACS_INT pos_byte = PT_BYTE;
unsigned char *p = PT_ADDR, *endp, *stop;
if (forwardp)
if (code == Scomment_fence)
{
/* Skip until first preceding unquoted comment_fence. */
- int found = 0, ini = from, ini_byte = from_byte;
+ int found = 0;
+ EMACS_INT ini = from, ini_byte = from_byte;
while (1)
{
while (from > stop)
{
temp_pos = from_byte;
- if (! NILP (current_buffer->enable_multibyte_characters))
+ if (! NILP (BVAR (current_buffer, enable_multibyte_characters)))
DEC_POS (temp_pos);
else
temp_pos--;
This includes chars with "quote" or "prefix" syntax (' or p). */)
(void)
{
- int beg = BEGV;
- int opoint = PT;
- int opoint_byte = PT_BYTE;
- int pos = PT;
- int pos_byte = PT_BYTE;
+ EMACS_INT beg = BEGV;
+ EMACS_INT opoint = PT;
+ EMACS_INT opoint_byte = PT_BYTE;
+ EMACS_INT pos = PT;
+ EMACS_INT pos_byte = PT_BYTE;
int c;
if (pos <= beg)
Fput (Qscan_error, Qerror_message,
make_pure_c_string ("Scan error"));
- DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments,
+ DEFVAR_BOOL ("parse-sexp-ignore-comments", parse_sexp_ignore_comments,
doc: /* Non-nil means `forward-sexp', etc., should treat comments as whitespace. */);
- DEFVAR_BOOL ("parse-sexp-lookup-properties", &parse_sexp_lookup_properties,
+ DEFVAR_BOOL ("parse-sexp-lookup-properties", parse_sexp_lookup_properties,
doc: /* Non-nil means `forward-sexp', etc., obey `syntax-table' property.
Otherwise, that text property is simply ignored.
See the info node `(elisp)Syntax Properties' for a description of the
`syntax-table' property. */);
words_include_escapes = 0;
- DEFVAR_BOOL ("words-include-escapes", &words_include_escapes,
+ DEFVAR_BOOL ("words-include-escapes", words_include_escapes,
doc: /* Non-nil means `forward-word', etc., should treat escape chars part of words. */);
- DEFVAR_BOOL ("multibyte-syntax-as-symbol", &multibyte_syntax_as_symbol,
+ DEFVAR_BOOL ("multibyte-syntax-as-symbol", multibyte_syntax_as_symbol,
doc: /* Non-nil means `scan-sexps' treats all multibyte characters as symbol. */);
multibyte_syntax_as_symbol = 0;
DEFVAR_BOOL ("open-paren-in-column-0-is-defun-start",
- &open_paren_in_column_0_is_defun_start,
+ open_paren_in_column_0_is_defun_start,
doc: /* *Non-nil means an open paren in column 0 denotes the start of a defun. */);
open_paren_in_column_0_is_defun_start = 1;
DEFVAR_LISP ("find-word-boundary-function-table",
- &Vfind_word_boundary_function_table,
+ Vfind_word_boundary_function_table,
doc: /*
Char table of functions to search for the word boundary.
Each function is called with two arguments; POS and LIMIT.
defsubr (&Sparse_partial_sexp);
}
-/* arch-tag: 3e297b9f-088e-4b64-8f4c-fb0b3443e412
- (do not change this comment) */