Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
21a59780
Commit
21a59780
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: reshuffle some code to harmonize two related functions
parent
b4fd08fa
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/files.c
+12
-11
src/files.c
with
12 additions
and
11 deletions
+12
-11
src/files.c
View file @
21a59780
...
...
@@ -2860,35 +2860,36 @@ bool writehist(FILE *hist, const filestruct *head)
/* Save the search and replace histories to ~/.nano/search_history. */
void
save_history
(
void
)
{
char
*
nanohist
;
char
*
searchhist
;
FILE
*
hist
;
/* Don't save unchanged or empty histories. */
if
(
!
history_has_changed
()
||
(
searchbot
->
lineno
==
1
&&
replacebot
->
lineno
==
1
))
return
;
nano
hist
=
histfilename
();
search
hist
=
histfilename
();
if
(
nanohist
!=
NULL
)
{
FILE
*
hist
=
fopen
(
nanohist
,
"wb"
);
if
(
searchhist
==
NULL
)
return
;
hist
=
fopen
(
searchhist
,
"wb"
);
if
(
hist
==
NULL
)
fprintf
(
stderr
,
_
(
"Error writing %s: %s
\n
"
),
nano
hist
,
fprintf
(
stderr
,
_
(
"Error writing %s: %s
\n
"
),
search
hist
,
strerror
(
errno
));
else
{
/* Make sure no one else can read from or write to the
* history file. */
chmod
(
nanohist
,
S_IRUSR
|
S_IWUSR
);
/* Don't allow others to read or write the history file. */
chmod
(
searchhist
,
S_IRUSR
|
S_IWUSR
);
if
(
!
writehist
(
hist
,
searchage
)
||
!
writehist
(
hist
,
replaceage
))
fprintf
(
stderr
,
_
(
"Error writing %s: %s
\n
"
),
nano
hist
,
fprintf
(
stderr
,
_
(
"Error writing %s: %s
\n
"
),
search
hist
,
strerror
(
errno
));
fclose
(
hist
);
}
free
(
nanohist
);
}
free
(
searchhist
);
}
/* Save the recorded last file positions to ~/.nano/filepos_history. */
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help