Commit Graph

288 Commits (4ff5c696e92427d00ad064925fc6f41a8efda8f2)

Author SHA1 Message Date
Ariadne Conill 4ff5c696e9 lobotomize gnulib 2021-12-04 08:48:53 -06:00
Hussam al-Homsi bb8f40989f tweaks: change 'return ++var;' to 'return var + 1;'
This avoids an unused and misleading assignment that might make
someone think the incremented variable will be used again.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-10-02 17:41:03 +02:00
Benno Schulenberg 49d8b99e4f softwrap: avoid time-consuming computations, to burden large files less
Whenever softwrap was toggled on or line numbers were toggled on/off or
the window was resized, the extra rows per line needed to be recomputed
for ALL the lines.  For large files with many long lines this was too
costly.

(This change causes the indicator to have an incorrect size when there
are many softwrapped chunks onscreen, but that will be addressed later.)

This fixes https://savannah.gnu.org/bugs/?60429.

Problem existed since version 5.0, since the indicator was introduced.
2021-04-21 16:40:20 +02:00
Benno Schulenberg fd023d6dcf tweaks: put the most likely condition first, for a quicker return
Also condense a comment.
2021-04-06 11:32:25 +02:00
Benno Schulenberg 8c25bd0e94 tweaks: elide two more instances of useless character copying
Just point at the relevant characters directly
instead of first copying them out.
2021-04-02 16:39:10 +02:00
Benno Schulenberg b6909d3737 build: fix compilation when configured with --enable-tiny
Commit 0c1bf429 from last week added two calls to digits()
for --constantshow.
2021-03-24 12:21:50 +01:00
Benno Schulenberg 6360e4170a copyright: update the years for the FSF 2021-01-11 14:22:51 +01:00
Benno Schulenberg ec9fc5d320 utils: die when trying to allocate zero bytes
This shouldn't occur, so go down when it does.
2020-10-29 16:18:03 +01:00
Benno Schulenberg 3c2eb96243 tweaks: rename two variables and improve two comments 2020-10-21 12:24:52 +02:00
Hussam al-Homsi c87bc1d55f tweaks: stop casting the return of malloc() and friends
Those casts are redundant, and sometimes ugly.  And as the types of
variables are extremely unlikely to change any more at this point,
the protection they offer against miscompilations is moot.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-08-31 12:17:27 +02:00
Benno Schulenberg c8a87b4d2a softwrap: initialize the 'extrarows' value for the magic line correctly
The make_new_node() function initializes 'extrarows' to a bad value
on purpose, to catch cases like this one where it doesn't get updated
properly.

This fixes https://savannah.gnu.org/bugs/?58890.
Reported-by: Jerry Kindall <kindall@gmail.com>

Bug existed since version 5.0, since the indicator was introduced.
2020-08-04 09:40:25 +02:00
Michalis Kokologiannakis 4940b02ae0 build: avoid compilation warnings by using memcpy() instead of strncpy()
When compiling with GCC 10.1.0 and -O2 -Wall, the strncpy() call
in measured_copy() produced two stringop-truncation warnings.

This addresses https://savannah.gnu.org/bugs/?58861.

Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-08-02 16:47:05 +02:00
Benno Schulenberg 90f6342fd1 tweaks: rename two header files, to be distinct and not an abbreviation 2020-06-20 12:09:31 +02:00
Benno Schulenberg 248d392c4d tweaks: rename a symbol, and actually use it where it is needed 2020-05-29 17:19:38 +02:00
Benno Schulenberg 079a679431 tweaks: rename two functions, to better indicate what they do 2020-04-15 17:20:03 +02:00
Benno Schulenberg 654d694e39 tweaks: simplify the counting of characters in a section
The line after the given section is always NULL (or when it is not,
it is intended to be NULL), so always subtract 1 at the end.
2020-04-09 12:58:41 +02:00
Benno Schulenberg 19a6120dc8 tweaks: rename a function, to be more general and clearer 2020-04-09 12:27:07 +02:00
Benno Schulenberg 59040169ed tweaks: get rid of a bunch of annoying casts, and thus condense the code 2020-03-29 20:17:32 +02:00
Benno Schulenberg 0cc2104257 tweaks: elide a parameter, by calling the relevant function beforehand
This means that in most cases mark_is_before_cursor() is called twice:
once before get_region() is called, and once by get_region() itself.
This small duplication of effort is acceptable: the affected functions
are not time critical, and it makes the code shorter.
2020-03-29 13:22:17 +02:00
Benno Schulenberg ae139021eb tweaks: rename four more functions, to get rid of an abbreviation
Also, improve their comments.
2020-03-12 15:54:19 +01:00
Benno Schulenberg 2bc5c1987c tweaks: factor out a three-line condition into a separate function
For clarity.
2020-03-05 16:09:56 +01:00
Benno Schulenberg be7e000389 tweaks: pull the NUL-terminating of a string into a function
Also, avoid copying one byte too many that afterward gets
overwritten with '\0'.
2020-02-20 17:08:32 +01:00
Benno Schulenberg 2148e857e5 copyright: update the years for significantly changed files 2020-01-15 12:11:56 +01:00
Benno Schulenberg afa4c6b9fc copyright: update the years for the FSF 2020-01-15 11:42:38 +01:00
Benno Schulenberg fa88fcc8f2 tweaks: rename a function, and elide a parameter that is always NULL
After the previous change, all remaining calls of parse_mbchar() have
NULL as their third parameter.  So, drop that parameter and remove the
chunk of code that handles it.  Also rename the function, as there are
already too many functions that start with "parse".
2019-10-21 12:35:14 +02:00
Benno Schulenberg c2d8641f01 chars: add a faster version of the character-parsing function
It elides a parameter that is always NULL, and elides two ifs
that always take the same path.
2019-10-21 12:24:23 +02:00
Benno Schulenberg 054559dc93 tweaks: rename three variables, to be more descriptive 2019-10-20 09:45:58 +02:00
Benno Schulenberg fdeab9b4c9 tweaks: order two functions more sensibly 2019-10-20 09:45:58 +02:00
Benno Schulenberg f26c121ca9 tweaks: adjust two comments, to better fit the actual functions 2019-10-20 09:45:58 +02:00
Benno Schulenberg 17c16a4bf5 tweaks: rename a function and elide its first parameter 2019-10-20 09:45:58 +02:00
Benno Schulenberg 46566572d6 utils: don't accept NULL for the string to be copied
This should not occur, so crash when it does happen.
2019-10-20 09:45:58 +02:00
Benno Schulenberg ba79602281 tweaks: condense two comments, and rename two parameters
Also use 'while' instead of 'for'.
2019-10-13 16:45:02 +02:00
Benno Schulenberg d256d0cbc0 tweaks: add a helper function without the ubiquitous NULL argument
For conciseness and clarity.
2019-10-13 12:24:27 +02:00
Benno Schulenberg 1075de1222 tweaks: rename two functions, to get rid of the "mb" abbreviation
Also, for me "move" is about moving the cursor.  But these functions
are about moving an index in a text, which is more general.
2019-06-09 19:37:56 +02:00
Benno Schulenberg 4e637cd1c7 tweaks: delete a now-unused function 2019-05-28 17:41:28 +02:00
Benno Schulenberg 65560a583c tweaks: rename a parameter and a variable, to be more distinct 2019-05-24 19:27:04 +02:00
Benno Schulenberg 35a791dee5 tweaks: remove two unneeded checks for NULL
If the rest of nano is correct, then these checks are superfluous and
only slow the loops down.  But if there is some incorrect code, then
let nano crash on dereferencing NULL so we can find and fix the bug.
2019-05-24 19:17:01 +02:00
Benno Schulenberg 98ffb19746 tweaks: stop checking for a NULL result from line_from_number()
No one ever reported seeing the message that was removed in commit
c039aaad one month ago, so most likely the code is correct and nano
never calls line_from_number() with a non-existent line number.
2019-05-24 19:08:29 +02:00
Benno Schulenberg 93edd12099 tweaks: rename a function, to be clearer and to stop using an old abbrev 2019-05-24 18:56:34 +02:00
Benno Schulenberg 8fe19e344f tweaks: use a more direct call when a single linestruct is deleted 2019-04-28 17:20:08 +02:00
Benno Schulenberg 896cfcef95 tweaks: when OR'ing, put the most likely condition first
Also, slightly reword a comment, adjust some whitespace, and use
a more direct comparison for equality.
2019-04-28 15:53:33 +02:00
Benno Schulenberg 37eccd3117 tweaks: rename a function, to be more fitting
Also, adjust some whitespace, for esthetics.
2019-04-28 11:01:51 +02:00
Benno Schulenberg 0b6889cbd8 tweaks: rename another function, to be distinct and fitting 2019-04-24 10:52:49 +02:00
Benno Schulenberg 00410d83fc tweaks: rename a function, to be distinct and fitting
It was hard to remember that the "pt" stood for "plus tabs", and the
"len" seemed to say it was about number of bytes instead of columns.
2019-04-24 10:52:35 +02:00
Benno Schulenberg c039aaad9d tweaks: remove several unneeded bad-state checks and their messages
No one ever reported seeing any of them, and each of these checks
has been there for at least a year.
2019-04-14 19:38:04 +02:00
Benno Schulenberg 691eb1145c tweaks: remove a function that is now unused 2019-04-04 14:53:53 +02:00
Benno Schulenberg cddfcb1b9d tweaks: rename a struct element, to make sense 2019-03-21 17:23:49 +01:00
Benno Schulenberg 6755b7c0a0 tweaks: rename four functions, to make more sense 2019-03-21 17:18:50 +01:00
Benno Schulenberg aac4fc46e9 tweaks: rename a type, to make more sense 2019-03-21 17:08:52 +01:00
Benno Schulenberg 85e895508b display: scroll horizontally one column earlier
In this way, for single-width characters, one can see what character is
ahead of the cursor before actually moving the cursor to that position,
and, for double-width characters, the cursor never sits on a placeholder
but always shows the character that is actually there.

This addresses https://savannah.gnu.org/bugs/?55716.
2019-03-07 20:34:31 +01:00