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
dd157f14
Commit
dd157f14
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: change a parameter of open_buffer() and invert its logic
parent
62491880
master
feature/match-parens
refactor/readbility
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/files.c
+8
-10
src/files.c
src/help.c
+1
-1
src/help.c
src/nano.c
+3
-3
src/nano.c
src/proto.h
+1
-1
src/proto.h
src/text.c
+1
-1
src/text.c
with
14 additions
and
16 deletions
+14
-16
src/files.c
View file @
dd157f14
...
...
@@ -406,13 +406,11 @@ void stat_with_alloc(const char *filename, struct stat **pstat)
}
#endif
/* !NANO_TINY */
/* This does one of three things. If the filename is "", just create
a new
* empty buffer.
Otherwise, read the given file into the existing buffer,
*
or
into a new buffer when
MULTIBUFFER is set or there is no
buffer
yet
. */
bool
open_buffer
(
const
char
*
filename
,
bool
undoable
)
/* This does one of three things. If the filename is "",
it
just create
s
*
a new
empty buffer.
When the filename is not empty, it reads that file
* into a new buffer when
requested, otherwise into the existing
buffer. */
bool
open_buffer
(
const
char
*
filename
,
bool
new_buffer
)
{
bool
new_buffer
=
(
openfile
==
NULL
||
ISSET
(
MULTIBUFFER
));
/* Whether we load into the current buffer or a new one. */
char
*
realname
;
/* The filename after tilde expansion. */
FILE
*
f
;
...
...
@@ -478,7 +476,7 @@ bool open_buffer(const char *filename, bool undoable)
/* If we have a non-new file, read it in. Then, if the buffer has
* no stat, update the stat, if applicable. */
if
(
rc
>
0
)
{
read_file
(
f
,
rc
,
realname
,
undoable
&&
!
new_buffer
,
new_buffer
);
read_file
(
f
,
rc
,
realname
,
!
new_buffer
,
new_buffer
);
#ifndef NANO_TINY
if
(
openfile
->
current_stat
==
NULL
)
stat_with_alloc
(
realname
,
&
openfile
->
current_stat
);
...
...
@@ -1121,7 +1119,7 @@ void do_insertfile(void)
#ifdef ENABLE_MULTIBUFFER
/* When in multibuffer mode, first open a blank buffer. */
if
(
ISSET
(
MULTIBUFFER
))
open_buffer
(
""
,
FALS
E
);
open_buffer
(
""
,
TRU
E
);
#endif
/* If the command is not empty, execute it and read its output
* into the buffer, and add the command to the history list. */
...
...
@@ -1148,8 +1146,8 @@ void do_insertfile(void)
/* Make sure the specified path is tilde-expanded. */
answer
=
free_and_assign
(
answer
,
real_dir_from_tilde
(
answer
));
/* Read the
specified file
into
the
current buffer. */
open_buffer
(
answer
,
TRUE
);
/* Read the
file into a new buffer or
into current buffer. */
open_buffer
(
answer
,
ISSET
(
MULTIBUFFER
)
);
}
#ifdef ENABLE_MULTIBUFFER
...
...
This diff is collapsed.
Click to expand it.
src/help.c
View file @
dd157f14
...
...
@@ -75,7 +75,7 @@ void wrap_the_help_text(bool redisplaying)
if
(
redisplaying
)
close_buffer
();
open_buffer
(
tempfilename
,
FALS
E
);
open_buffer
(
tempfilename
,
TRU
E
);
remove_magicline
();
prepare_for_display
();
...
...
This diff is collapsed.
Click to expand it.
src/nano.c
View file @
dd157f14
...
...
@@ -1164,7 +1164,7 @@ bool scoop_stdin(void)
}
/* Read the input into a new buffer. */
open_buffer
(
""
,
FALS
E
);
open_buffer
(
""
,
TRU
E
);
read_file
(
stream
,
0
,
"stdin"
,
TRUE
,
FALSE
);
openfile
->
edittop
=
openfile
->
fileage
;
...
...
@@ -2616,7 +2616,7 @@ int main(int argc, char **argv)
optind
++
;
if
(
!
scoop_stdin
())
continue
;
}
else
if
(
!
open_buffer
(
argv
[
optind
++
],
FALS
E
))
}
else
if
(
!
open_buffer
(
argv
[
optind
++
],
TRU
E
))
continue
;
/* If a position was given on the command line, go there. */
...
...
@@ -2636,7 +2636,7 @@ int main(int argc, char **argv)
* directories, then open a blank buffer and allow editing. Otherwise,
* switch from the last opened file to the next, that is: the first. */
if
(
openfile
==
NULL
)
{
open_buffer
(
""
,
FALS
E
);
open_buffer
(
""
,
TRU
E
);
UNSET
(
VIEW_MODE
);
}
#ifdef ENABLE_MULTIBUFFER
...
...
This diff is collapsed.
Click to expand it.
src/proto.h
View file @
dd157f14
...
...
@@ -267,7 +267,7 @@ void do_uncut_text(void);
/* Most functions in files.c. */
void
initialize_buffer_text
(
void
);
void
set_modified
(
void
);
bool
open_buffer
(
const
char
*
filename
,
bool
undoable
);
bool
open_buffer
(
const
char
*
filename
,
bool
new_buffer
);
#ifdef ENABLE_SPELLER
void
replace_buffer
(
const
char
*
filename
);
#ifndef NANO_TINY
...
...
This diff is collapsed.
Click to expand it.
src/text.c
View file @
dd157f14
...
...
@@ -3226,7 +3226,7 @@ void do_linter(void)
goto
free_lints_and_return
;
}
else
if
(
i
==
1
)
{
SET
(
MULTIBUFFER
);
open_buffer
(
curlint
->
filename
,
FALS
E
);
open_buffer
(
curlint
->
filename
,
TRU
E
);
}
else
{
char
*
dontwantfile
=
mallocstrcpy
(
NULL
,
curlint
->
filename
);
lintstruct
*
restlint
=
NULL
;
...
...
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