Commit Graph

5698 Commits (f2150d3f98d95f485b01cb69475c98c6f6797467)

Author SHA1 Message Date
Benno Schulenberg 0293eac1d1 files: report an unwritable file in a separate message
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.
2016-06-03 21:18:14 +02:00
Benno Schulenberg 0172cb0e83 tweaks: improve a couple of comments 2016-06-02 12:12:12 +02:00
Benno Schulenberg 56f067a284 chars: ensure that files are sorted also when strncasecmp() is strange
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.
2016-06-01 21:59:25 +02:00
Benno Schulenberg 660584c1ea search: find, and thus delete, only exact matches from history
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>
2016-06-01 21:47:06 +02:00
Benno Schulenberg e198c85053 tweaks: rename two variables, and elide a third 2016-06-01 19:49:47 +02:00
Benno Schulenberg 05e2a6d259 chars: a control character can never be an invalid multibyte sequence
The function is_cntrl_mbchar() has always been called successfully before
calling control_mbrep(), so the passed character *is* a valid sequence.
2016-06-01 13:08:40 +02:00
Benno Schulenberg 21d9bd1107 tweaks: rename some variables to be more readable 2016-06-01 13:04:32 +02:00
Benno Schulenberg 5864d97590 tweaks: harmonize the routine for tabs with the one for spaces 2016-06-01 13:04:22 +02:00
Benno Schulenberg 3ac37642c8 screen: check for the most frequent character first: a space 2016-06-01 13:04:08 +02:00
Benno Schulenberg b42887fe14 tweaks: adjust a couple of comments 2016-06-01 13:04:00 +02:00
Benno Schulenberg 4172268bd2 chars: the representation of control characters is always two columns wide 2016-06-01 13:03:43 +02:00
Benno Schulenberg a9f79a6130 tweaks: reindent and rewrap a few lines, and shorten a comment 2016-06-01 13:03:26 +02:00
Mike Scalora 115aeda69b text: keep the file size correct when undoing/redoing a comment/uncomment
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>
2016-05-31 21:36:22 +02:00
Benno Schulenberg 17cf833b9c tweaks: normalize some whitespace 2016-05-30 09:09:36 +02:00
Benno Schulenberg aaab6e57e0 screen: when using positionlog, show as much of the file as possible
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.
2016-05-28 21:20:39 +02:00
Benno Schulenberg fbd817fb94 utils: rename some variables, to match those in strnlenpt() 2016-05-28 13:23:41 +02:00
Benno Schulenberg e3e3f655ee tweaks: use an available macro to silence a compiler warning 2016-05-27 21:48:38 +02:00
Benno Schulenberg 3129ff687a tweaks: rename a variable, because nothing is returned there 2016-05-27 21:43:39 +02:00
Benno Schulenberg 1d3d30776a tweaks: more consistently use * instead of [0] when checking for '\0' 2016-05-27 21:31:55 +02:00
Benno Schulenberg 2fae87d9a5 tweaks: harmonize some indentations, elide an #ifdef, and rewrap a line 2016-05-27 21:22:56 +02:00
Benno Schulenberg a5b3f00d78 chars: make comparing multibyte strings twice as fast
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.)
2016-05-27 10:37:43 +02:00
Benno Schulenberg 1bffa17c01 tweaks: rename two more variables 2016-05-27 10:36:54 +02:00
Benno Schulenberg a151167416 tweaks: rename some variables for contrast 2016-05-27 10:36:12 +02:00
Mike Scalora 6a2032f5b0 new feature: comment/uncomment current line or selected lines
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>
2016-05-25 22:29:50 +02:00
Benno Schulenberg d3bd855c9d tweaks: rename a function, and move the sorting there too 2016-05-25 12:09:22 +02:00
Rishabh Dave bd3f156044 browser: move all openings and closings of a directory to the same function
Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-05-25 12:02:33 +02:00
Benno Schulenberg 3b21659661 tweaks: elide four #ifdefs, improve one comment and unwrap some others 2016-05-24 17:55:24 +02:00
Benno Schulenberg bf64386717 tweaks: rename a variable, for aptness 2016-05-24 17:52:16 +02:00
Benno Schulenberg 1b902d6267 tweaks: elide unneeded intermediate assignments 2016-05-24 17:52:01 +02:00
Benno Schulenberg 619044e83d tweaks: put some conditions in a better order: the main one first 2016-05-24 17:51:50 +02:00
Benno Schulenberg e0e788e218 tweaks: reshuffle a few things 2016-05-23 21:34:02 +02:00
Benno Schulenberg a617d9c05e tweaks: remove a redundant assignment 2016-05-23 21:25:00 +02:00
Benno Schulenberg 99e6293cd0 tweaks: remove an unnecessary intermediate assignment 2016-05-23 20:57:08 +02:00
Benno Schulenberg 286b6a9088 tweaks: rename a variable, to indicate better what it contains
And to contrast it more with 'answer'.
2016-05-23 20:46:58 +02:00
Benno Schulenberg 27e07d2af5 tweaks: rename two variables, to avoid using a name for different purposes
When calling do_prompt(), 'ans' is used to offer a default answer or the
answer given so far.
2016-05-23 20:30:01 +02:00
Benno Schulenberg 1228b2c05b tweaks: rename a variable, to indicate what it contains 2016-05-23 20:29:52 +02:00
Benno Schulenberg d6a04b8a62 tweaks: improve a few comments 2016-05-23 20:29:31 +02:00
Benno Schulenberg fbb6208d15 browser, files: use full path in error message when in confined mode
The relative path could be . or .. or even empty, which is uninformative.

This fixes the last part of https://savannah.gnu.org/bugs/?47798.
2016-05-22 11:41:58 +02:00
Benno Schulenberg c0285682e4 startup: show an error message when argument of --operatingdir is invalid
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.
2016-05-22 11:41:58 +02:00
Benno Schulenberg 60da39cdf7 files: fix a memory leak 2016-05-21 21:35:12 +02:00
Benno Schulenberg 2e75c22759 browser: fix a memory leak 2016-05-21 21:35:02 +02:00
Benno Schulenberg 9576eb62e6 browser: show a message when getcwd() fails, instead of just beeping 2016-05-21 21:34:25 +02:00
Benno Schulenberg f9fe9a7d57 backups: take an unlikely condition into account
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.
2016-05-21 13:58:41 +02:00
Benno Schulenberg 8bf5e58f37 tweaks: improve a few comments 2016-05-21 13:58:41 +02:00
Benno Schulenberg f6fdeeb3af files: remove a redundant condition 2016-05-21 13:58:41 +02:00
Benno Schulenberg e65352bc8a files: when writing a lockfile fails, continue loading the file
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.
2016-05-21 13:58:41 +02:00
Benno Schulenberg c8f530af93 statusbar: add a non-beeping message type that does not get overwritten
Error messages about lock files should not get overwritten by purely
informational messages, only by alerting ones.

This fixes https://savannah.gnu.org/bugs/?47963.
2016-05-21 13:58:09 +02:00
Benno Schulenberg c9d1936f02 files: don't reuse a variable that may have been modified by dirname()
The variable 'namecopy' has been passed to dirname(), so it is likely
to have been changed when it contains a slash.  So, use a new variable
instead.  Also, free the result of display_string().

This fixes https://savannah.gnu.org/bugs/?47956.
2016-05-18 21:34:16 +02:00
Benno Schulenberg faf5227bc5 files: remove a superfluous condition, and do not ignore a "No"
Having just opened a fresh buffer, 'openfile->next' will never be NULL,
because the list is circular.

Second, when compiled with --disable-nultibuffer, and deciding not to
override an existing lock, the 'return FALSE' should *not* be skipped,
because otherwise the named file will be opened after all.

This fixes an unreported bug.
2016-05-18 17:59:22 +02:00
Benno Schulenberg bc33539b11 files: upgrade the locking errors, so they will not be overwritten
Make the failures to read or write a lock file into important messages,
so they will not be overwritten by the number of lines read.
2016-05-18 12:08:54 +02:00