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
807f5c2e
Commit
807f5c2e
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: do not leak the indentation when all lines are empty
parent
1b2a091d
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/text.c
+12
-10
src/text.c
with
12 additions
and
10 deletions
+12
-10
src/text.c
View file @
807f5c2e
...
...
@@ -296,6 +296,18 @@ void do_indent(void)
bot
=
top
;
}
/* Go through the lines to see if there's a non-empty one. */
for
(
f
=
top
;
f
!=
bot
->
next
;
f
=
f
->
next
)
{
if
(
f
->
data
[
0
]
!=
'\0'
)
break
;
}
/* If all lines are empty, there is nothing to do. */
if
(
f
==
bot
->
next
)
{
free
(
line_indent
);
return
;
}
/* Set the indentation to either a bunch of spaces or a single tab. */
if
(
ISSET
(
TABS_TO_SPACES
))
{
charset
(
line_indent
,
' '
,
tabsize
);
...
...
@@ -307,16 +319,6 @@ void do_indent(void)
line_indent
[
line_indent_len
]
=
'\0'
;
/* Go through the lines to see if there's a non-empty one. */
for
(
f
=
top
;
f
!=
bot
->
next
;
f
=
f
->
next
)
{
if
(
f
->
data
[
0
]
!=
'\0'
)
break
;
}
/* If all lines are empty, there is nothing to do. */
if
(
f
==
bot
->
next
)
return
;
/* Go through each of the lines, but skip empty ones. */
for
(
f
=
top
;
f
!=
bot
->
next
;
f
=
f
->
next
)
{
size_t
line_len
=
strlen
(
f
->
data
);
...
...
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