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
79a4bf81
Commit
79a4bf81
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: rename five variables, for uniformity with a few others
parent
b77e6bd9
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
+10
-11
src/nano.c
src/text.c
+14
-14
src/text.c
with
24 additions
and
25 deletions
+24
-25
src/nano.c
View file @
79a4bf81
...
...
@@ -1813,9 +1813,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#ifndef NANO_TINY
size_t
orig_lenpt
=
0
;
#endif
char
*
char_buf
=
charalloc
(
mb_cur_max
());
int
char_
buf_
len
;
int
char_len
;
current_len
=
strlen
(
openfile
->
current
->
data
);
...
...
@@ -1838,12 +1837,12 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
}
/* Get the next multibyte character. */
char_
buf_
len
=
parse_mbchar
(
output
+
i
,
char_buf
,
NULL
);
char_len
=
parse_mbchar
(
output
+
i
,
char_buf
,
NULL
);
i
+=
char_
buf_
len
;
i
+=
char_len
;
/* If controls are not allowed, ignore an ASCII control character. */
if
(
!
allow_cntrls
&&
is_ascii_cntrl_char
(
*
(
output
+
i
-
char_
buf_
len
)))
if
(
!
allow_cntrls
&&
is_ascii_cntrl_char
(
*
(
output
+
i
-
char_len
)))
continue
;
/* If we're adding to the magicline, create a new magicline. */
...
...
@@ -1857,13 +1856,13 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
/* Make room for the new character and copy it into the line. */
openfile
->
current
->
data
=
charealloc
(
openfile
->
current
->
data
,
current_len
+
char_
buf_
len
+
1
);
charmove
(
openfile
->
current
->
data
+
openfile
->
current_x
+
char_
buf_
len
,
current_len
+
char_len
+
1
);
charmove
(
openfile
->
current
->
data
+
openfile
->
current_x
+
char_len
,
openfile
->
current
->
data
+
openfile
->
current_x
,
current_len
-
openfile
->
current_x
+
1
);
strncpy
(
openfile
->
current
->
data
+
openfile
->
current_x
,
char_buf
,
char_
buf_
len
);
current_len
+=
char_
buf_
len
;
char_len
);
current_len
+=
char_len
;
openfile
->
totsize
++
;
set_modified
();
...
...
@@ -1873,10 +1872,10 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
/* Note that current_x has not yet been incremented. */
if
(
openfile
->
mark_set
&&
openfile
->
current
==
openfile
->
mark_begin
&&
openfile
->
current_x
<
openfile
->
mark_begin_x
)
openfile
->
mark_begin_x
+=
char_
buf_
len
;
openfile
->
mark_begin_x
+=
char_len
;
#endif
openfile
->
current_x
+=
char_
buf_
len
;
openfile
->
current_x
+=
char_len
;
#ifndef NANO_TINY
update_undo
(
ADD
);
...
...
This diff is collapsed.
Click to expand it.
src/text.c
View file @
79a4bf81
...
...
@@ -102,7 +102,7 @@ void do_deletion(undo_type action)
if
(
openfile
->
current
->
data
[
openfile
->
current_x
]
!=
'\0'
)
{
/* We're in the middle of a line: delete the current character. */
int
char_
buf_
len
=
parse_mbchar
(
openfile
->
current
->
data
+
int
char_len
=
parse_mbchar
(
openfile
->
current
->
data
+
openfile
->
current_x
,
NULL
,
NULL
);
size_t
line_len
=
strlen
(
openfile
->
current
->
data
+
openfile
->
current_x
);
...
...
@@ -118,16 +118,16 @@ void do_deletion(undo_type action)
/* Move the remainder of the line "in", over the current character. */
charmove
(
&
openfile
->
current
->
data
[
openfile
->
current_x
],
&
openfile
->
current
->
data
[
openfile
->
current_x
+
char_
buf_
len
],
line_len
-
char_
buf_
len
+
1
);
&
openfile
->
current
->
data
[
openfile
->
current_x
+
char_len
],
line_len
-
char_len
+
1
);
null_at
(
&
openfile
->
current
->
data
,
openfile
->
current_x
+
line_len
-
char_
buf_
len
);
line_len
-
char_len
);
#ifndef NANO_TINY
/* Adjust the mark if it is after the cursor on the current line. */
if
(
openfile
->
mark_set
&&
openfile
->
mark_begin
==
openfile
->
current
&&
openfile
->
mark_begin_x
>
openfile
->
current_x
)
openfile
->
mark_begin_x
-=
char_
buf_
len
;
openfile
->
mark_begin_x
-=
char_len
;
#endif
/* Adjust the file size. */
openfile
->
totsize
--
;
...
...
@@ -1222,12 +1222,12 @@ void add_undo(undo_type action)
case
DEL
:
if
(
u
->
begin
!=
strlen
(
openfile
->
current
->
data
))
{
char
*
char_buf
=
charalloc
(
mb_cur_max
()
+
1
);
int
char_
buf_
len
=
parse_mbchar
(
&
openfile
->
current
->
data
[
u
->
begin
],
int
char_len
=
parse_mbchar
(
&
openfile
->
current
->
data
[
u
->
begin
],
char_buf
,
NULL
);
null_at
(
&
char_buf
,
char_
buf_
len
);
null_at
(
&
char_buf
,
char_len
);
u
->
strdata
=
char_buf
;
if
(
u
->
type
==
BACK
)
u
->
mark_begin_x
+=
char_
buf_
len
;
u
->
mark_begin_x
+=
char_len
;
break
;
}
/* Else purposely fall into the line-joining code. */
...
...
@@ -1355,8 +1355,8 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
openfile
->
current
->
data
,
(
unsigned
long
)
openfile
->
current_x
,
(
unsigned
long
)
u
->
begin
);
#endif
char
*
char_buf
=
charalloc
(
mb_cur_max
());
size_
t
char_
buf_
len
=
parse_mbchar
(
&
openfile
->
current
->
data
[
u
->
mark_begin_x
],
char_buf
,
NULL
);
u
->
strdata
=
addstrings
(
u
->
strdata
,
u
->
strdata
?
strlen
(
u
->
strdata
)
:
0
,
char_buf
,
char_
buf_
len
);
in
t
char_len
=
parse_mbchar
(
&
openfile
->
current
->
data
[
u
->
mark_begin_x
],
char_buf
,
NULL
);
u
->
strdata
=
addstrings
(
u
->
strdata
,
u
->
strdata
?
strlen
(
u
->
strdata
)
:
0
,
char_buf
,
char_len
);
#ifdef DEBUG
fprintf
(
stderr
,
" >> current undo data is
\"
%s
\"\n
"
,
u
->
strdata
);
#endif
...
...
@@ -1367,14 +1367,14 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
case
BACK
:
case
DEL
:
{
char
*
char_buf
=
charalloc
(
mb_cur_max
());
size_
t
char_
buf_
len
=
parse_mbchar
(
&
openfile
->
current
->
data
[
openfile
->
current_x
],
char_buf
,
NULL
);
in
t
char_len
=
parse_mbchar
(
&
openfile
->
current
->
data
[
openfile
->
current_x
],
char_buf
,
NULL
);
if
(
openfile
->
current_x
==
u
->
begin
)
{
/* They're deleting. */
u
->
strdata
=
addstrings
(
u
->
strdata
,
strlen
(
u
->
strdata
),
char_buf
,
char_
buf_
len
);
u
->
strdata
=
addstrings
(
u
->
strdata
,
strlen
(
u
->
strdata
),
char_buf
,
char_len
);
u
->
mark_begin_x
=
openfile
->
current_x
;
}
else
if
(
openfile
->
current_x
==
u
->
begin
-
char_
buf_
len
)
{
}
else
if
(
openfile
->
current_x
==
u
->
begin
-
char_len
)
{
/* They're backspacing. */
u
->
strdata
=
addstrings
(
char_buf
,
char_
buf_
len
,
u
->
strdata
,
strlen
(
u
->
strdata
));
u
->
strdata
=
addstrings
(
char_buf
,
char_len
,
u
->
strdata
,
strlen
(
u
->
strdata
));
u
->
begin
=
openfile
->
current_x
;
}
else
{
/* They deleted something else on the line. */
...
...
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