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
2c024a74
Commit
2c024a74
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: adjust or correct some comments, and rename a function
Also, reshuffle a condition so it takes up less space.
parent
ab8698df
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/nano.c
+13
-18
src/nano.c
src/proto.h
+1
-1
src/proto.h
with
14 additions
and
19 deletions
+14
-19
src/nano.c
View file @
2c024a74
...
...
@@ -588,12 +588,14 @@ void die(const char *msg, ...)
va_list
ap
;
openfilestruct
*
firstone
=
openfile
;
/* Switch on the cursor and leave curses mode. */
curs_set
(
1
);
endwin
();
/* Restore the old terminal settings. */
tcsetattr
(
0
,
TCSANOW
,
&
oldterm
);
/* Display the dying message. */
va_start
(
ap
,
msg
);
vfprintf
(
stderr
,
msg
,
ap
);
va_end
(
ap
);
...
...
@@ -604,13 +606,14 @@ void die(const char *msg, ...)
if
(
ISSET
(
LOCKING
)
&&
openfile
->
lock_filename
)
delete_lockfile
(
openfile
->
lock_filename
);
#endif
/* If the current file buffer was modified, save it. */
if
(
openfile
->
modified
)
{
/* If the buffer is partitioned, unpartition it first. */
/* If the current buffer was modified, ensure it is unpartitioned,
* then save it. When in restricted mode, we don't save anything,
* because it would write files not mentioned on the command line. */
if
(
openfile
->
modified
&&
!
ISSET
(
RESTRICTED
))
{
if
(
filepart
!=
NULL
)
unpartition_filestruct
(
&
filepart
);
die_save_fil
e
(
openfile
->
filename
,
openfile
->
current_stat
);
emergency_sav
e
(
openfile
->
filename
,
openfile
->
current_stat
);
}
filepart
=
NULL
;
...
...
@@ -624,21 +627,14 @@ void die(const char *msg, ...)
exit
(
1
);
}
/* Save the current
file
under the
name specified in die_filename, which
* is modified to be unique
if necessary
. */
void
die_save_fil
e
(
const
char
*
die_filename
,
struct
stat
*
die_stat
)
/* Save the current
buffer
under the
given name.
*
If necessary, the name
is modified to be unique. */
void
emergency_sav
e
(
const
char
*
die_filename
,
struct
stat
*
die_stat
)
{
char
*
targetname
;
bool
failed
=
TRUE
;
/* If we're using restricted mode, don't write any emergency backup
* files, since that would allow reading from or writing to files
* not specified on the command line. */
if
(
ISSET
(
RESTRICTED
))
return
;
/* If we can't save, we have really bad problems, but we might as
* well try. */
/* If the buffer has no name, simply call it "nano". */
if
(
*
die_filename
==
'\0'
)
die_filename
=
"nano"
;
...
...
@@ -657,9 +653,8 @@ void die_save_file(const char *die_filename, struct stat *die_stat)
_
(
"Too many backup files?"
));
#ifndef NANO_TINY
/* Try and chmod/chown the save file to the values of the original file,
* but don't worry if it fails because we're supposed to be bailing as
* fast as possible. */
/* Try to chmod/chown the saved file to the values of the original file,
* but ignore any failure as we are in a hurry to get out. */
if
(
die_stat
)
{
IGNORE_CALL_RESULT
(
chmod
(
targetname
,
die_stat
->
st_mode
));
IGNORE_CALL_RESULT
(
chown
(
targetname
,
die_stat
->
st_uid
,
...
...
This diff is collapsed.
Click to expand it.
src/proto.h
View file @
2c024a74
...
...
@@ -421,7 +421,7 @@ void say_there_is_no_help(void);
#endif
void
finish
(
void
);
void
die
(
const
char
*
msg
,
...);
void
die_save_fil
e
(
const
char
*
die_filename
,
struct
stat
*
die_stat
);
void
emergency_sav
e
(
const
char
*
die_filename
,
struct
stat
*
die_stat
);
void
window_init
(
void
);
void
do_exit
(
void
);
void
close_and_go
(
void
);
...
...
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