Skip to content
GitLab
Menu
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
4bbbb185
Commit
4bbbb185
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: adjust the indentation after the previous change
Also rename a variable, to match the saving routine.
parent
6645351b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/files.c
+36
-36
src/files.c
with
36 additions
and
36 deletions
+36
-36
src/files.c
View file @
4bbbb185
...
...
@@ -2777,62 +2777,62 @@ int check_dotnano(void)
/* Load the search and replace histories from ~/.nano/search_history. */
void
load_history
(
void
)
{
char
*
nano
hist
=
histfilename
();
char
*
search
hist
=
histfilename
();
char
*
legacyhist
=
legacyhistfilename
();
struct
stat
hstat
;
FILE
*
hist
;
/* If no home directory was found, we can't do anything. */
if
(
nano
hist
==
NULL
||
legacyhist
==
NULL
)
if
(
search
hist
==
NULL
||
legacyhist
==
NULL
)
return
;
/* If there is an old history file, migrate it. */
/* (To be removed in 2018.) */
if
(
stat
(
legacyhist
,
&
hstat
)
!=
-
1
&&
stat
(
nano
hist
,
&
hstat
)
==
-
1
)
{
if
(
rename
(
legacyhist
,
nano
hist
)
==
-
1
)
if
(
stat
(
legacyhist
,
&
hstat
)
!=
-
1
&&
stat
(
search
hist
,
&
hstat
)
==
-
1
)
{
if
(
rename
(
legacyhist
,
search
hist
)
==
-
1
)
history_error
(
N_
(
"Detected a legacy nano history file (%s) which I tried to move
\n
"
"to the preferred location (%s) but encountered an error: %s"
),
legacyhist
,
nano
hist
,
strerror
(
errno
));
legacyhist
,
search
hist
,
strerror
(
errno
));
else
history_error
(
N_
(
"Detected a legacy nano history file (%s) which I moved
\n
"
"to the preferred location (%s)
\n
(see the nano FAQ about this change)"
),
legacyhist
,
nano
hist
);
legacyhist
,
search
hist
);
}
hist
=
fopen
(
nano
hist
,
"rb"
);
hist
=
fopen
(
search
hist
,
"rb"
);
if
(
hist
==
NULL
)
{
if
(
errno
!=
ENOENT
)
{
/* When reading failed, don't save history when we quit. */
UNSET
(
HISTORYLOG
);
history_error
(
N_
(
"Error reading %s: %s"
),
nano
hist
,
if
(
hist
==
NULL
)
{
if
(
errno
!=
ENOENT
)
{
/* When reading failed, don't save history when we quit. */
UNSET
(
HISTORYLOG
);
history_error
(
N_
(
"Error reading %s: %s"
),
search
hist
,
strerror
(
errno
));
}
}
else
{
/* Load a history list (first the search history, then the
* replace history) from the oldest entry to the newest.
* Assume the last history entry is a blank line. */
filestruct
**
history
=
&
search_history
;
char
*
line
=
NULL
;
size_t
buf_len
=
0
;
ssize_t
read
;
while
((
read
=
getline
(
&
line
,
&
buf_len
,
hist
))
>
0
)
{
line
[
--
read
]
=
'\0'
;
if
(
read
>
0
)
{
/* Encode any embedded NUL as 0x0A. */
unsunder
(
line
,
read
);
update_history
(
history
,
line
);
}
else
history
=
&
replace_history
;
}
fclose
(
hist
);
free
(
line
);
}
}
else
{
/* Load the two history lists -- first the search history, then
* the replace history -- from the oldest entry to the newest.
* The two lists are separated by an empty line. */
filestruct
**
history
=
&
search_history
;
char
*
line
=
NULL
;
size_t
buf_len
=
0
;
ssize_t
read
;
while
((
read
=
getline
(
&
line
,
&
buf_len
,
hist
))
>
0
)
{
line
[
--
read
]
=
'\0'
;
if
(
read
>
0
)
{
/* Encode any embedded NUL as 0x0A. */
unsunder
(
line
,
read
);
update_history
(
history
,
line
);
}
else
history
=
&
replace_history
;
}
fclose
(
hist
);
free
(
line
);
}
free
(
nano
hist
);
free
(
legacyhist
);
free
(
search
hist
);
free
(
legacyhist
);
}
/* Write the lines of a history list, starting with the line at head, to
...
...
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