Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
7074fde6
Commit
7074fde6
authored
Nov 21, 1994
by
Francesco Potortì
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added code for automatically saving and restoring the match data
when a filter or sentinel tries to modify it.
parent
82734236
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
1 deletion
+68
-1
src/emacs.c
src/emacs.c
+5
-0
src/lisp.h
src/lisp.h
+3
-0
src/process.c
src/process.c
+8
-1
src/search.c
src/search.c
+52
-0
No files found.
src/emacs.c
View file @
7074fde6
...
...
@@ -98,6 +98,10 @@ int inhibit_window_system;
priority; Those functions have their own extern declaration. */
int
emacs_priority
;
/* If non-zero a filter or a sentinel is running. Tested to save the match
data on the first attempt to change it inside asynchronous code. */
int
running_asynch_code
;
#ifdef BSD_PGRPS
/* See sysdep.c. */
extern
int
inherited_pgroup
;
...
...
@@ -697,6 +701,7 @@ Usage: %s [-t term] [--terminal term] [-nw] [--no-windows] [--batch]\n\
init_alloc
();
init_eval
();
init_data
();
running_asynch_code
=
0
;
#ifdef MSDOS
/* Call early 'cause init_environment needs it. */
...
...
src/lisp.h
View file @
7074fde6
...
...
@@ -1404,6 +1404,7 @@ extern Lisp_Object Vfundamental_mode_abbrev_table;
/* defined in search.c */
extern
Lisp_Object
Fstring_match
();
extern
Lisp_Object
Fscan_buffer
();
extern
void
restore_match_data
();
/* defined in minibuf.c */
...
...
@@ -1499,6 +1500,8 @@ void shut_down_emacs ( /* int signal, int no_x, Lisp_Object stuff */ );
extern
int
noninteractive
;
/* Nonzero means don't do use window-system-specific display code */
extern
int
inhibit_window_system
;
/* Nonzero means that a filter or a sentinel is running. */
extern
int
running_asynch_code
;
/* defined in process.c */
extern
Lisp_Object
Fget_process
(),
Fget_buffer_process
(),
Fprocessp
();
...
...
src/process.c
View file @
7074fde6
...
...
@@ -2350,13 +2350,17 @@ read_process_output (proc, channel)
specbind
(
Qinhibit_quit
,
Qt
);
specbind
(
Qlast_nonmenu_event
,
Qt
);
running_asynch_code
=
1
;
internal_condition_case_1
(
read_process_output_call
,
Fcons
(
outstream
,
Fcons
(
proc
,
Fcons
(
make_string
(
chars
,
nchars
),
Fcons
(
make_string
(
chars
,
nchars
),
Qnil
))),
!
NILP
(
Vdebug_on_error
)
?
Qnil
:
Qerror
,
read_process_output_error_handler
);
running_asynch_code
=
0
;
restore_match_data
();
/* Handling the process output should not deactivate the mark. */
Vdeactivate_mark
=
odeactivate
;
...
...
@@ -3233,11 +3237,14 @@ exec_sentinel (proc, reason)
specbind
(
Qinhibit_quit
,
Qt
);
specbind
(
Qlast_nonmenu_event
,
Qt
);
running_asynch_code
=
1
;
internal_condition_case_1
(
read_process_output_call
,
Fcons
(
sentinel
,
Fcons
(
proc
,
Fcons
(
reason
,
Qnil
))),
!
NILP
(
Vdebug_on_error
)
?
Qnil
:
Qerror
,
exec_sentinel_error_handler
);
running_asynch_code
=
0
;
restore_match_data
();
Vdeactivate_mark
=
odeactivate
;
if
(
!
EQ
(
Fcurrent_buffer
(),
obuffer
))
...
...
src/search.c
View file @
7074fde6
...
...
@@ -206,6 +206,9 @@ looking_at_1 (string, posix)
register
int
i
;
struct
re_pattern_buffer
*
bufp
;
if
(
running_asynch_code
)
save_search_regs
();
CHECK_STRING
(
string
,
0
);
bufp
=
compile_pattern
(
string
,
&
search_regs
,
(
!
NILP
(
current_buffer
->
case_fold_search
)
...
...
@@ -284,6 +287,9 @@ string_match_1 (regexp, string, start, posix)
int
s
;
struct
re_pattern_buffer
*
bufp
;
if
(
running_asynch_code
)
save_search_regs
();
CHECK_STRING
(
regexp
,
0
);
CHECK_STRING
(
string
,
1
);
...
...
@@ -928,6 +934,9 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt, posix)
unsigned
char
*
p1
,
*
p2
;
int
s1
,
s2
;
if
(
running_asynch_code
)
save_search_regs
();
/* Null string is found at starting position. */
if
(
len
==
0
)
{
...
...
@@ -1845,6 +1854,9 @@ LIST should have been created by calling `match-data' previously.")
register
int
i
;
register
Lisp_Object
marker
;
if
(
running_asynch_code
)
save_search_regs
();
if
(
!
CONSP
(
list
)
&&
!
NILP
(
list
))
list
=
wrong_type_argument
(
Qconsp
,
list
);
...
...
@@ -1914,6 +1926,46 @@ LIST should have been created by calling `match-data' previously.")
return
Qnil
;
}
/* If non-zero the match data have been saved in saved_search_regs
during the execution of a sentinel or filter. */
static
int
search_regs_saved
=
0
;
static
struct
re_registers
saved_search_regs
;
/* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data
if asynchronous code (filter or sentinel) is running. */
static
void
save_search_regs
()
{
if
(
!
search_regs_saved
)
{
saved_search_regs
.
num_regs
=
search_regs
.
num_regs
;
saved_search_regs
.
start
=
search_regs
.
start
;
saved_search_regs
.
end
=
search_regs
.
end
;
search_regs
.
num_regs
=
0
;
search_regs_saved
=
1
;
}
}
/* Called upon exit from filters and sentinels. */
void
restore_match_data
()
{
if
(
search_regs_saved
)
{
if
(
search_regs
.
num_regs
>
0
)
{
xfree
(
search_regs
.
start
);
xfree
(
search_regs
.
end
);
}
search_regs
.
num_regs
=
saved_search_regs
.
num_regs
;
search_regs
.
start
=
saved_search_regs
.
start
;
search_regs
.
end
=
saved_search_regs
.
end
;
search_regs_saved
=
0
;
}
}
/* Quote a string to inactivate reg-expr chars */
DEFUN
(
"regexp-quote"
,
Fregexp_quote
,
Sregexp_quote
,
1
,
1
,
0
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment