Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
4d2a0879
Commit
4d2a0879
authored
Dec 16, 1996
by
Richard M. Stallman
Browse files
(Finsert_file_contents): Handle BEG and END non-nil
when REPLACE is non-nil.
parent
ddbe99e0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
src/fileio.c
src/fileio.c
+11
-6
No files found.
src/fileio.c
View file @
4d2a0879
...
@@ -3117,8 +3117,6 @@ and (2) it puts less data in the undo list.")
...
@@ -3117,8 +3117,6 @@ and (2) it puts less data in the undo list.")
if
(
!
NILP
(
replace
))
if
(
!
NILP
(
replace
))
{
{
replace
=
Qnil
;
replace
=
Qnil
;
XSETFASTINT
(
beg
,
0
);
XSETFASTINT
(
end
,
st
.
st_size
);
del_range_1
(
BEGV
,
ZV
,
0
);
del_range_1
(
BEGV
,
ZV
,
0
);
}
}
#else
/* not DOS_NT */
#else
/* not DOS_NT */
...
@@ -3129,6 +3127,13 @@ and (2) it puts less data in the undo list.")
...
@@ -3129,6 +3127,13 @@ and (2) it puts less data in the undo list.")
int
same_at_end
=
ZV
;
int
same_at_end
=
ZV
;
int
overlap
;
int
overlap
;
if
(
XINT
(
beg
)
!=
0
)
{
if
(
lseek
(
fd
,
XINT
(
beg
),
0
)
<
0
)
report_file_error
(
"Setting file position"
,
Fcons
(
filename
,
Qnil
));
}
immediate_quit
=
1
;
immediate_quit
=
1
;
QUIT
;
QUIT
;
/* Count how many chars at the start of the file
/* Count how many chars at the start of the file
...
@@ -3155,7 +3160,7 @@ and (2) it puts less data in the undo list.")
...
@@ -3155,7 +3160,7 @@ and (2) it puts less data in the undo list.")
immediate_quit
=
0
;
immediate_quit
=
0
;
/* If the file matches the buffer completely,
/* If the file matches the buffer completely,
there's no need to replace anything. */
there's no need to replace anything. */
if
(
same_at_start
-
BEGV
==
st
.
st_size
)
if
(
same_at_start
-
BEGV
==
XINT
(
end
)
)
{
{
close
(
fd
);
close
(
fd
);
specpdl_ptr
--
;
specpdl_ptr
--
;
...
@@ -3172,7 +3177,7 @@ and (2) it puts less data in the undo list.")
...
@@ -3172,7 +3177,7 @@ and (2) it puts less data in the undo list.")
int
total_read
,
nread
,
bufpos
,
curpos
,
trial
;
int
total_read
,
nread
,
bufpos
,
curpos
,
trial
;
/* At what file position are we now scanning? */
/* At what file position are we now scanning? */
curpos
=
st
.
st_size
-
(
ZV
-
same_at_end
);
curpos
=
XINT
(
end
)
-
(
ZV
-
same_at_end
);
/* If the entire file matches the buffer tail, stop the scan. */
/* If the entire file matches the buffer tail, stop the scan. */
if
(
curpos
==
0
)
if
(
curpos
==
0
)
break
;
break
;
...
@@ -3216,8 +3221,8 @@ and (2) it puts less data in the undo list.")
...
@@ -3216,8 +3221,8 @@ and (2) it puts less data in the undo list.")
same_at_end
+=
overlap
;
same_at_end
+=
overlap
;
/* Arrange to read only the nonmatching middle part of the file. */
/* Arrange to read only the nonmatching middle part of the file. */
XSETFASTINT
(
beg
,
same_at_start
-
BEGV
);
XSETFASTINT
(
beg
,
XINT
(
beg
)
+
(
same_at_start
-
BEGV
)
)
;
XSETFASTINT
(
end
,
st
.
st_size
-
(
ZV
-
same_at_end
));
XSETFASTINT
(
end
,
XINT
(
end
)
-
(
ZV
-
same_at_end
));
del_range_1
(
same_at_start
,
same_at_end
,
0
);
del_range_1
(
same_at_start
,
same_at_end
,
0
);
/* Insert from the file at the proper position. */
/* Insert from the file at the proper position. */
...
...
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