That is: don't mix the number of lines read with a warning about the
file being unwritable -- the former is just convenience information,
the latter is a must-see.
This fixes https://savannah.gnu.org/bugs/?48047.
When running in a non-UTF locale, and when strncasecmp() suffers from
the same defect as strncmp(), make sure not to pass a length with the
high bit set.
This reverts commit df8c3de from six years ago, which prevented a crash
on the Armel/Maemo platforms but causes nano to lose history items.
The strncmp() function on those platforms treats size_t numbers with
the high bit set as if they were zero. To avoid that, use a number
that cannot be seen as negative, as suggested by <alpha@qzx.com>.
This fixes https://savannah.gnu.org/bugs/?48048.
Tested-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Store the file sizes from before and after the commenting/uncommenting
in the undo struct, so they can be restored when undoing or redoing.
This fixes https://savannah.gnu.org/bugs/?48062.
Signed-off-by: Mike Scalora <mike@scalora.org>
When opening a file that was edited before, and the remembered position
is near the end of the file, then don't center the target line but show
the last line of the file on the bottom line of the screen, thus showing
as much of the file content as possible.
This addresses https://savannah.gnu.org/bugs/?46243.
Instead of parsing every multibyte character twice, first with
parse_mbchar() and then with mbtowc(), just let mbtowc() do all
the work. This makes searching for a fixed string twice as fast.
This also gets rid of four variables and lots of memory allocations.
(And, more importantly: it stops nano messing up the internal state
of the multibyte-to-wide character conversion, and thus would make
the calls to mbtowc_reset() superfluous.)
This allows for commenting or uncommenting a line or a bunch of lines
with a single keystroke (default binding: M-3). The characters used
for commenting/uncommenting are specified by the active syntax file.
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Mike Scalora <mike@scalora.org>
Move the initialization of the operating directory to after the
initialization of the screen, so that the above error can be shown.
This fixes the first part of https://savannah.gnu.org/bugs/?47798.
Between the first stat (that sets 'realexists') and the second stat
(directly after), the file might have disappeared, which would mean
that current_stat would be NULL. Prevent dereferencing this further
down.
Only when the user decides not to override an existing lockfile should
loading the corresponding file be skipped. Any failure to write the
lockfile should be ignored -- the file itself should be loaded anyway.
This fixes https://savannah.gnu.org/bugs/?47945.