Benno Schulenberg
aafda2358f
tweaks: rename two variables, away from abbreviations
2020-07-23 09:44:14 +02:00
Benno Schulenberg
6b9084ad09
tweaks: reshuffle a few lines, to elide an 'if' from the most common path
...
And for compactness.
2020-07-22 20:32:38 +02:00
Benno Schulenberg
d0501d0ebd
tweaks: update a translator hint, and add another
2020-07-22 11:38:29 +02:00
Benno Schulenberg
ba5a191f26
gnulib: update to its current upstream state
2020-07-22 11:25:04 +02:00
Benno Schulenberg
364a1518de
tweaks: reshuffle some lines, to better separate the three cases
2020-07-22 11:07:20 +02:00
Benno Schulenberg
93b2877758
tweaks: use three switches instead of cascading ifs, for brevity
2020-07-22 10:56:41 +02:00
Benno Schulenberg
832037e2ec
tweaks: condense some cases to a single line, for more clarity
...
And return directly for codes that will not be changed any more.
2020-07-22 10:43:24 +02:00
Benno Schulenberg
ad2920acd0
tweaks: handle the double escapes directly, instead of going round again
...
Immediately pull the available extra character from the keyboard buffer,
instead of cycling through the whole circus again.
2020-07-22 10:17:48 +02:00
Benno Schulenberg
e59a0f5e77
build: replace the non-standard backslash escape "\e" with "\x1B"
...
Older compilers do not understand "\e". Also, it's not in the standard
(see http://open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf , §6.4.4.4).
This addresses https://savannah.gnu.org/bugs/?58799 .
Reported-by: Henry Bent <henry.r.bent@gmail.com>
2020-07-22 09:17:57 +02:00
Benno Schulenberg
fd10c0eadd
tweaks: rake a common statement to the end of the case
...
With the two situations that need to preserve the escape counter
now returning directly, the resetting of this counter can happen
at the end of each case block.
2020-07-21 14:03:18 +02:00
Benno Schulenberg
7e53fcb581
tweaks: remove two redundant conditions, and make a more direct return
...
The escape-parsing routine nowadays returns FOREIGN_SEQUENCE instead
of ERR when encountering an unknown sequence. So, with the two cases
that demand ERR now handled directly, there is no need to check for
ERR any more.
2020-07-21 14:02:55 +02:00
Benno Schulenberg
8249f3560f
tweaks: normalize the indentation after the previous change
2020-07-20 19:46:27 +02:00
Benno Schulenberg
dd1b16cd54
tweaks: trim an ASCII case, as the function is called only for UTF-8
2020-07-20 19:37:40 +02:00
Benno Schulenberg
43b39ed04f
tweaks: use knowledge of Unicode to skip the general multibyte conversion
...
The relevant range is so small (128 bytes) that "manual" conversion
is much faster (and a bit shorter, eliding two variables).
2020-07-20 19:31:25 +02:00
Benno Schulenberg
17a8b24fe5
tweaks: skip the conversion to multibyte for plain ASCII codes
...
Converting an ASCII code to "multibyte" is a no-op: it stays one byte.
2020-07-20 19:16:45 +02:00
Benno Schulenberg
b9db967bc4
tweaks: reshuffle some lines, for esthetics
...
There is no need to reset the digit counter (because this counter
matters only when the escape counter equals two) -- resetting the
escape counter is enough.
2020-07-20 19:06:16 +02:00
Benno Schulenberg
2a5d129738
tweaks: rename a variable, and normalize the indentation
2020-07-20 18:25:19 +02:00
Benno Schulenberg
6980cfbf70
tweaks: change a 'switch' to 'if', to elide a dummy 'return'
2020-07-20 18:21:43 +02:00
Benno Schulenberg
a0d2e63c8e
tweaks: improve four comments
2020-07-20 17:15:06 +02:00
Benno Schulenberg
57c52de99a
tweaks: rename a function, and move it to before the one that calls it
2020-07-20 17:04:48 +02:00
Benno Schulenberg
9067f7a0c7
tweaks: elide a variable, by returning the result directly
2020-07-20 16:54:22 +02:00
Benno Schulenberg
e4fa0b54a2
tweaks: remove two superfluous assignments
...
The digit counter will be reset to zero the next time when <Esc>
is pressed, and the byte holder gets re-initialized when the next
first digit is pressed. And the escape counter is reset to zero
after returning from a result-giving call of get_byte_kbinput().
2020-07-20 16:28:36 +02:00
Benno Schulenberg
b41405233f
tweaks: remove some superfluous conditions
...
When get_byte_kbinput() is called, it has already been determined that
the keyboard input is a digit from zero to nine (or from zero to two
for the first digit), so there is no need to check this again.
2020-07-20 12:40:26 +02:00
Benno Schulenberg
88561506c9
tweaks: improve two comments, and reshuffle some lines for conciseness
2020-07-20 11:47:10 +02:00
Benno Schulenberg
a08ca026f0
input: reset the counters when a three-digit sequence is not completed
...
When <Esc><Esc> is followed by digit 0 or 1 or 2 but then NOT two more
digits follow, then both the escape counter and the digit counter should
start afresh when a new ESC code arrives.
This fixes https://savannah.gnu.org/bugs/?58788 .
Bug existed since before version 2.0.6.
2020-07-20 11:19:44 +02:00
Benno Schulenberg
180a53cc0c
files: warn the root user when all the write bits are missing
...
Root has carte blanche to both read unreadable files and write
unwritable files -- the file system does not prevent this. So,
alert root when opening a file that is intended to be read-only.
This fulfills https://savannah.gnu.org/bugs/?58685 .
Requested-by: Marius Bakke <mbakke@fastmail.com>
2020-07-20 10:26:45 +02:00
Benno Schulenberg
d18cfb26cd
tweaks: adjust the indentation after the previous change
2020-07-19 11:52:57 +02:00
Benno Schulenberg
eb70578c5e
tweaks: do not use 'switch' when there are just two possibilities
...
Also, remove an unneeded 'if', as parse_escape_sequence() is only
ever called when there are at least two bytes after the Esc code.
(If there were not, the 'for' loop after calling convert_sequence()
would use an uninitialized 'consumed' value.)
2020-07-19 11:52:47 +02:00
Benno Schulenberg
63efc59758
tweaks: don't check for escape sequences that start with a lowercase "o"
...
Such escape sequences don't exist -- those mistaken sequences were
removed in commit 4991b3bb
from half a year ago.
2020-07-19 11:50:30 +02:00
Benno Schulenberg
dcd34b246a
tweaks: move a function to the file where it is used the most
...
Also, fully exclude the function from the tiny version.
2020-07-19 10:43:26 +02:00
Benno Schulenberg
b0dcb15f94
tweaks: elide a function that is too sparse
...
The two calls of the function can be replaced with two lines each.
2020-07-17 18:40:34 +02:00
Benno Schulenberg
7dbfbbb8d6
tweaks: reshuffle a few lines, for conciseness
2020-07-17 17:13:43 +02:00
Benno Schulenberg
4cefd699ca
tweaks: shorten an error message, to be appropriate in all situations
...
Saying "Cannot write backup %s" is misleading when it is the original
file that cannot be reread.
2020-07-17 17:10:46 +02:00
Benno Schulenberg
8eddf7bc26
tweaks: reshuffle a condition, to avoid a repetition of code
2020-07-17 16:53:48 +02:00
Benno Schulenberg
2623f39c7b
backup: when rereading the original file fails, ask the user what to do
...
Rereading is unlikely to fail, but *if* it fails, maybe there is a
serious problem and the user wants to try and fix it before saving
the buffer and thus overwriting the original file.
2020-07-17 16:50:25 +02:00
Benno Schulenberg
da71322000
tweaks: rename two labels, for brevity
2020-07-17 16:24:53 +02:00
Benno Schulenberg
292e505e01
tweaks: rename two variables, to avoid a repetitive prefix
...
Also, fold a condition into an assignment, for conciseness.
2020-07-17 16:23:22 +02:00
Benno Schulenberg
a322dab482
tweaks: elide a function that is called just once
...
It also nicely groups the backup stuff together in a single function.
2020-07-16 15:03:06 +02:00
Benno Schulenberg
0ed1695fd4
build: fix miscompilation for --enable-{tiny,color,nanorc}
...
This should have been part of commit 096e3627
from a month ago.
2020-07-16 12:47:43 +02:00
Benno Schulenberg
60d31d2ea6
tweaks: avoid a warning about an unused variable in the tiny version
2020-07-16 12:41:01 +02:00
Benno Schulenberg
b744eec1a9
tweaks: remove an incorrect mention of umask() from a comment
...
Since commit f8366cd5
, umask() is no longer used.
2020-07-15 10:52:49 +02:00
Benno Schulenberg
a6f64212ae
tweaks: rename a function, to not shadow a variable, and elide parameter
2020-07-15 10:52:49 +02:00
Benno Schulenberg
a6cee410ef
tweaks: normalize the indentation after the previous change
2020-07-15 10:52:49 +02:00
Benno Schulenberg
f7682730bd
files: make a backup only when requested, not an unrequested failsafe one
...
After thinking about it, I don't like it that nano makes an unrequested
failsafe backup: in the vast, vast majority of cases it is a waste both
of time and of disk wear. If the user is worried about data loss, they
can use --backup. The fsync() after writing out the buffer (added in
commit a84cdaaa
) already reduces the chances on data loss somewhat.
2020-07-15 10:50:36 +02:00
Benno Schulenberg
5f90e067f1
tweaks: rename a parameter and a variable, to be more meaningful
2020-07-14 17:31:47 +02:00
Benno Schulenberg
b0f563980d
tweaks: elide an unneeded call of strlen(), and copy NUL byte with string
2020-07-14 17:22:08 +02:00
Benno Schulenberg
258e7c6e65
oops -- restore an accidentally changed file
2020-07-14 15:22:22 +02:00
Benno Schulenberg
65321f9234
files: do not make a failsafe backup when in restricted mode
...
When in restricted mode, nano should not write to any other file
than to the ones mentioned on the command line.
2020-07-14 15:19:50 +02:00
Benno Schulenberg
bde8858a3a
tweaks: rename a variable, to avoid overrepetition of 'backup'
...
Also, reshuffle three calls of fclose().
2020-07-14 13:52:34 +02:00
Benno Schulenberg
a2b7fc1c81
tweaks: slightly improve a comment and the ordering of some lines
2020-07-14 13:00:34 +02:00