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
17431c60
Commit
17431c60
authored
Feb 21, 1993
by
Richard M. Stallman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Fskip_syntax_backward): New function.
(Fskip_syntax_forward): Likewise. (skip_chars): New argument syntaxp.
parent
3a69360c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
24 deletions
+76
-24
src/search.c
src/search.c
+76
-24
No files found.
src/search.c
View file @
17431c60
...
...
@@ -357,7 +357,7 @@ Returns the distance traveled, either zero or positive.")
(
string
,
lim
)
Lisp_Object
string
,
lim
;
{
return
skip_chars
(
1
,
string
,
lim
);
return
skip_chars
(
1
,
0
,
string
,
lim
);
}
DEFUN
(
"skip-chars-backward"
,
Fskip_chars_backward
,
Sskip_chars_backward
,
1
,
2
,
0
,
...
...
@@ -367,12 +367,36 @@ Returns the distance traveled, either zero or negative.")
(
string
,
lim
)
Lisp_Object
string
,
lim
;
{
return
skip_chars
(
0
,
string
,
lim
);
return
skip_chars
(
0
,
0
,
string
,
lim
);
}
DEFUN
(
"skip-syntax-forward"
,
Fskip_syntax_forward
,
Sskip_syntax_forward
,
1
,
2
,
0
,
"Move point forward across chars in specified syntax classes.
\n
\
SYNTAX is a string of syntax code characters.
\n
\
Stop before a char whose syntax is not in SYNTAX, or at position LIM.
\n
\
If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX.
\n
\
This function returns the distance traveled, either zero or positive."
)
(
syntax
,
lim
)
Lisp_Object
syntax
,
lim
;
{
return
skip_chars
(
1
,
1
,
syntax
,
lim
);
}
DEFUN
(
"skip-syntax-backward"
,
Fskip_syntax_backward
,
Sskip_syntax_backward
,
1
,
2
,
0
,
"Move point backward across chars in specified syntax classes.
\n
\
SYNTAX is a string of syntax code characters.
\n
\
Stop on reaching a char whose syntax is not in SYNTAX, or at position LIM.
\n
\
If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX.
\n
\
This function returns the distance traveled, either zero or negative."
)
(
syntax
,
lim
)
Lisp_Object
syntax
,
lim
;
{
return
skip_chars
(
0
,
1
,
syntax
,
lim
);
}
Lisp_Object
skip_chars
(
forwardp
,
string
,
lim
)
int
forwardp
;
skip_chars
(
forwardp
,
syntaxp
,
string
,
lim
)
int
forwardp
,
syntaxp
;
Lisp_Object
string
,
lim
;
{
register
unsigned
char
*
p
,
*
pend
;
...
...
@@ -405,29 +429,36 @@ skip_chars (forwardp, string, lim)
negate
=
1
;
p
++
;
}
/* Find the characters specified and set their elements of fastmap. */
/* Find the characters specified and set their elements of fastmap.
If syntaxp, each character counts as itself.
Otherwise, handle backslashes and ranges specially */
while
(
p
!=
pend
)
{
c
=
*
p
++
;
if
(
c
==
'\\'
)
{
if
(
p
==
pend
)
break
;
c
=
*
p
++
;
}
if
(
p
!=
pend
&&
*
p
==
'-'
)
if
(
syntaxp
)
fastmap
[
c
]
=
1
;
else
{
p
++
;
if
(
p
==
pend
)
break
;
while
(
c
<=
*
p
)
if
(
c
==
'\\'
)
{
fastmap
[
c
]
=
1
;
c
++
;
if
(
p
==
pend
)
break
;
c
=
*
p
++
;
}
if
(
p
!=
pend
&&
*
p
==
'-'
)
{
p
++
;
if
(
p
==
pend
)
break
;
while
(
c
<=
*
p
)
{
fastmap
[
c
]
=
1
;
c
++
;
}
p
++
;
}
p
++
;
else
fastmap
[
c
]
=
1
;
}
else
fastmap
[
c
]
=
1
;
}
/* If ^ was the first character, complement the fastmap. */
...
...
@@ -440,15 +471,34 @@ skip_chars (forwardp, string, lim)
int
start_point
=
point
;
immediate_quit
=
1
;
if
(
forward
p
)
if
(
syntax
p
)
{
while
(
point
<
XINT
(
lim
)
&&
fastmap
[
FETCH_CHAR
(
point
)])
SET_PT
(
point
+
1
);
if
(
forwardp
)
{
while
(
point
<
XINT
(
lim
)
&&
fastmap
[(
unsigned
char
)
syntax_code_spec
[(
int
)
SYNTAX
(
FETCH_CHAR
(
point
))]])
SET_PT
(
point
+
1
);
}
else
{
while
(
point
>
XINT
(
lim
)
&&
fastmap
[(
unsigned
char
)
syntax_code_spec
[(
int
)
SYNTAX
(
FETCH_CHAR
(
point
-
1
))]])
SET_PT
(
point
-
1
);
}
}
else
{
while
(
point
>
XINT
(
lim
)
&&
fastmap
[
FETCH_CHAR
(
point
-
1
)])
SET_PT
(
point
-
1
);
if
(
forwardp
)
{
while
(
point
<
XINT
(
lim
)
&&
fastmap
[
FETCH_CHAR
(
point
)])
SET_PT
(
point
+
1
);
}
else
{
while
(
point
>
XINT
(
lim
)
&&
fastmap
[
FETCH_CHAR
(
point
-
1
)])
SET_PT
(
point
-
1
);
}
}
immediate_quit
=
0
;
...
...
@@ -1446,6 +1496,8 @@ syms_of_search ()
defsubr
(
&
Slooking_at
);
defsubr
(
&
Sskip_chars_forward
);
defsubr
(
&
Sskip_chars_backward
);
defsubr
(
&
Sskip_syntax_forward
);
defsubr
(
&
Sskip_syntax_backward
);
defsubr
(
&
Ssearch_forward
);
defsubr
(
&
Ssearch_backward
);
defsubr
(
&
Sword_search_forward
);
...
...
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