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
c2a0c78d
Commit
c2a0c78d
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: rename a variable and a type, to be less confusing
parent
97f4fe26
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/files.c
+22
-22
src/files.c
src/nano.h
+1
-1
src/nano.h
src/proto.h
+3
-3
src/proto.h
with
26 additions
and
26 deletions
+26
-26
src/files.c
View file @
c2a0c78d
...
...
@@ -1695,15 +1695,15 @@ int copy_file(FILE *inn, FILE *out)
*
* tmp means we are writing a temporary file in a secure fashion. We
* use it when spell checking or dumping the file on an error. If
*
appen
d is APPEND, it means we are appending instead of overwriting.
* If
appen
d is PREPEND, it means we are prepending instead of
*
metho
d is APPEND, it means we are appending instead of overwriting.
* If
metho
d is PREPEND, it means we are prepending instead of
* overwriting. If nonamechange is TRUE, we don't change the current
* filename. nonamechange is ignored if tmp is FALSE, we're appending,
* or we're prepending.
*
* Return TRUE on success or FALSE on error. */
bool
write_file
(
const
char
*
name
,
FILE
*
f_open
,
bool
tmp
,
append_type
appen
d
,
bool
nonamechange
)
bool
write_file
(
const
char
*
name
,
FILE
*
f_open
,
bool
tmp
,
kind_of_writing_type
metho
d
,
bool
nonamechange
)
{
bool
retval
=
FALSE
;
/* Instead of returning in this function, you should always
...
...
@@ -1769,7 +1769,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
* only if the file has not been modified by someone else since nano
* opened it. */
if
(
ISSET
(
BACKUP_FILE
)
&&
!
tmp
&&
realexists
&&
openfile
->
current_stat
&&
(
appen
d
!=
OVERWRITE
||
openfile
->
mark_set
||
(
metho
d
!=
OVERWRITE
||
openfile
->
mark_set
||
openfile
->
current_stat
->
st_mtime
==
st
.
st_mtime
))
{
int
backup_fd
;
FILE
*
backup_file
;
...
...
@@ -1948,7 +1948,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
}
/* If we're prepending, copy the file to a temp file. */
if
(
appen
d
==
PREPEND
)
{
if
(
metho
d
==
PREPEND
)
{
int
fd_source
;
FILE
*
f_source
=
NULL
;
...
...
@@ -1997,7 +1997,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
if
(
f_open
==
NULL
)
{
/* Now open the file in place. Use O_EXCL if tmp is TRUE. This
* is copied from joe, because wiggy says so *shrug*. */
fd
=
open
(
realname
,
O_WRONLY
|
O_CREAT
|
((
appen
d
==
APPEND
)
?
fd
=
open
(
realname
,
O_WRONLY
|
O_CREAT
|
((
metho
d
==
APPEND
)
?
O_APPEND
:
(
tmp
?
O_EXCL
:
O_TRUNC
)),
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
|
S_IROTH
|
S_IWOTH
);
...
...
@@ -2013,7 +2013,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
goto
cleanup_and_exit
;
}
f
=
fdopen
(
fd
,
(
appen
d
==
APPEND
)
?
"ab"
:
"wb"
);
f
=
fdopen
(
fd
,
(
metho
d
==
APPEND
)
?
"ab"
:
"wb"
);
if
(
f
==
NULL
)
{
statusline
(
ALERT
,
_
(
"Error writing %s: %s"
),
realname
,
...
...
@@ -2079,7 +2079,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
}
/* If we're prepending, open the temp file, and append it to f. */
if
(
appen
d
==
PREPEND
)
{
if
(
metho
d
==
PREPEND
)
{
int
fd_source
;
FILE
*
f_source
=
NULL
;
...
...
@@ -2111,7 +2111,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
goto
cleanup_and_exit
;
}
if
(
!
tmp
&&
appen
d
==
OVERWRITE
)
{
if
(
!
tmp
&&
metho
d
==
OVERWRITE
)
{
/* If we must set the filename, and it changed, adjust things. */
if
(
!
nonamechange
&&
strcmp
(
openfile
->
filename
,
realname
)
!=
0
)
{
#ifndef DISABLE_COLOR
...
...
@@ -2164,7 +2164,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
/* Write a marked selection from a file out to disk. Return TRUE on
* success or FALSE on error. */
bool
write_marked_file
(
const
char
*
name
,
FILE
*
f_open
,
bool
tmp
,
append_type
appen
d
)
kind_of_writing_type
metho
d
)
{
bool
retval
;
bool
old_modified
=
openfile
->
modified
;
...
...
@@ -2188,7 +2188,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
added_magicline
=
TRUE
;
}
retval
=
write_file
(
name
,
f_open
,
tmp
,
appen
d
,
TRUE
);
retval
=
write_file
(
name
,
f_open
,
tmp
,
metho
d
,
TRUE
);
/* If we added a magicline, remove it now. */
if
(
added_magicline
)
...
...
@@ -2214,7 +2214,7 @@ int do_writeout(bool exiting)
{
int
i
;
bool
result
=
FALSE
;
append_type
appen
d
=
OVERWRITE
;
kind_of_writing_type
metho
d
=
OVERWRITE
;
char
*
given
;
/* The filename we offer, or what the user typed so far. */
bool
maychange
=
(
openfile
->
filename
[
0
]
==
'\0'
);
...
...
@@ -2250,13 +2250,13 @@ int do_writeout(bool exiting)
* it allows reading from or writing to files not specified on
* the command line. */
if
(
openfile
->
mark_set
&&
!
exiting
&&
!
ISSET
(
RESTRICTED
))
msg
=
(
appen
d
==
PREPEND
)
?
_
(
"Prepend Selection to File"
)
:
(
appen
d
==
APPEND
)
?
_
(
"Append Selection to File"
)
:
msg
=
(
metho
d
==
PREPEND
)
?
_
(
"Prepend Selection to File"
)
:
(
metho
d
==
APPEND
)
?
_
(
"Append Selection to File"
)
:
_
(
"Write Selection to File"
);
else
#endif
/* !NANO_TINY */
msg
=
(
appen
d
==
PREPEND
)
?
_
(
"File Name to Prepend to"
)
:
(
appen
d
==
APPEND
)
?
_
(
"File Name to Append to"
)
:
msg
=
(
metho
d
==
PREPEND
)
?
_
(
"File Name to Prepend to"
)
:
(
metho
d
==
APPEND
)
?
_
(
"File Name to Append to"
)
:
_
(
"File Name to Write"
);
present_path
=
mallocstrcpy
(
present_path
,
"./"
);
...
...
@@ -2332,10 +2332,10 @@ int do_writeout(bool exiting)
}
else
#endif
/* !NANO_TINY */
if
(
func
==
prepend_void
)
{
append
=
(
appen
d
==
PREPEND
)
?
OVERWRITE
:
PREPEND
;
method
=
(
metho
d
==
PREPEND
)
?
OVERWRITE
:
PREPEND
;
continue
;
}
else
if
(
func
==
append_void
)
{
append
=
(
appen
d
==
APPEND
)
?
OVERWRITE
:
APPEND
;
method
=
(
metho
d
==
APPEND
)
?
OVERWRITE
:
APPEND
;
continue
;
}
else
if
(
func
==
do_help_void
)
{
continue
;
...
...
@@ -2360,7 +2360,7 @@ int do_writeout(bool exiting)
}
#endif
if
(
appen
d
==
OVERWRITE
)
{
if
(
metho
d
==
OVERWRITE
)
{
size_t
answer_len
=
strlen
(
answer
);
bool
name_exists
,
do_warning
;
char
*
full_answer
,
*
full_filename
;
...
...
@@ -2449,10 +2449,10 @@ int do_writeout(bool exiting)
* writing to files not specified on the command line. */
#ifndef NANO_TINY
if
(
openfile
->
mark_set
&&
!
exiting
&&
!
ISSET
(
RESTRICTED
))
result
=
write_marked_file
(
answer
,
NULL
,
FALSE
,
appen
d
);
result
=
write_marked_file
(
answer
,
NULL
,
FALSE
,
metho
d
);
else
#endif
result
=
write_file
(
answer
,
NULL
,
FALSE
,
appen
d
,
FALSE
);
result
=
write_file
(
answer
,
NULL
,
FALSE
,
metho
d
,
FALSE
);
break
;
}
...
...
This diff is collapsed.
Click to expand it.
src/nano.h
View file @
c2a0c78d
...
...
@@ -173,7 +173,7 @@ typedef enum {
typedef
enum
{
OVERWRITE
,
APPEND
,
PREPEND
}
append
_type
;
}
kind_of_writing
_type
;
typedef
enum
{
UPWARD
,
DOWNWARD
...
...
This diff is collapsed.
Click to expand it.
src/proto.h
View file @
c2a0c78d
...
...
@@ -317,11 +317,11 @@ int delete_lockfile(const char *lockfilename);
int
write_lockfile
(
const
char
*
lockfilename
,
const
char
*
origfilename
,
bool
modified
);
#endif
int
copy_file
(
FILE
*
inn
,
FILE
*
out
);
bool
write_file
(
const
char
*
name
,
FILE
*
f_open
,
bool
tmp
,
append_type
appen
d
,
bool
nonamechange
);
bool
write_file
(
const
char
*
name
,
FILE
*
f_open
,
bool
tmp
,
kind_of_writing_type
metho
d
,
bool
nonamechange
);
#ifndef NANO_TINY
bool
write_marked_file
(
const
char
*
name
,
FILE
*
f_open
,
bool
tmp
,
append_type
appen
d
);
kind_of_writing_type
metho
d
);
#endif
int
do_writeout
(
bool
exiting
);
void
do_writeout_void
(
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