Compare commits

..

129 Commits

Author SHA1 Message Date
Benno Schulenberg
be62368d54 po: update translations and regenerate POT file and PO files 2017-03-31 11:07:01 +02:00
Benno Schulenberg
032030566c bump version numbers and add a news item for the 2.8.0 release 2017-03-31 10:54:55 +02:00
Benno Schulenberg
bc9862fbff tweaks: condense some declarations by reshuffling 2017-03-29 21:35:56 +02:00
Benno Schulenberg
582a624998 tweaks: frob some parentheses and other things, to be more consistent 2017-03-29 19:30:37 +02:00
Benno Schulenberg
c7282e8821 tweaks: reshuffle two declarations for a more consistent order 2017-03-29 10:35:11 +02:00
Benno Schulenberg
1f9a6ab336 tweaks: factor out a bit of common code 2017-03-29 10:30:41 +02:00
Benno Schulenberg
33cefa9208 tweaks: elide an intermediate variable 2017-03-29 10:20:41 +02:00
Benno Schulenberg
873e3d6fa6 tweaks: don't loop over an initializer 2017-03-29 10:13:08 +02:00
Benno Schulenberg
54e4505b2f tweaks: frob a couple of comments 2017-03-28 19:44:41 +02:00
Benno Schulenberg
8091d0a574 tweaks: simplify and correct a computation
The leftedge variable is a column number, not an x position.
2017-03-28 19:24:37 +02:00
David Lawrence Ramsey
93c6248956 display: don't compensate for chunks before firstcolumn
The number of rows to draw shouldn't be compensated for the chunks
of edittop that are before firstcolumn, because they are offscreen.

This completes the fix for https://savannah.gnu.org/bugs/?50621.
2017-03-28 19:10:45 +02:00
David Lawrence Ramsey
66ef8f45a3 display: don't draw more chunks than the screen can hold
There is no need to always increase nrows by 1 or 2 -- an increase
of 1 is only needed when the line that borders on the scrolled region
needs to redrawn too: when this line was horizontally scrolled or when
the mark is on.

This fixes https://savannah.gnu.org/bugs/?50621.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-28 12:32:51 +02:00
David Lawrence Ramsey
d01756bb69 moving: determine the correct leftedge when paging up/down too
The change in commit 244a503d for the <Up> and <Down> keys
needs to be done for <PageUp> and <PageDown> too.
2017-03-28 12:32:47 +02:00
Benno Schulenberg
644fedcb61 tweaks: reshuffle some more lines and improve four comments 2017-03-28 11:24:32 +02:00
Benno Schulenberg
da3a015f7d tweaks: reshuffle some lines and adjust some comments 2017-03-28 10:38:08 +02:00
Benno Schulenberg
bc876ca729 moving: /do/ redraw the prior line when the viewport hasn't changed
The complementary test on current_y should only be done when doing
a scroll-only, because only then the prior line can be offscreen.

This fixes https://savannah.gnu.org/bugs/?50658.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-28 10:31:45 +02:00
Benno Schulenberg
9cf980700c moving: don't try to redraw lines that have gone outside the viewport
When scrolling backward, it is not just the bottom line of the screen
that doesn't need to be redrawn: also the line /before/ the top line
doesn't need a redraw.  Mutatis mutandis for scrolling forward.

This fixes https://savannah.gnu.org/bugs/?50657.
2017-03-27 19:44:21 +02:00
Benno Schulenberg
244a503ddc moving: the current chunk cannot be beyond the last chunk of a line
When determining the leftedge of the current chunk, it is not simply
the leftedge that corresponds to the placewewant, but the leftedge that
corresponds to the minimum of the placewewant and the full line span.

This fixes https://savannah.gnu.org/bugs/?50653.
2017-03-27 17:45:39 +02:00
Benno Schulenberg
c277cd6e5b tweaks: reshuffle some statements, to avoid double assignments 2017-03-27 11:38:52 +02:00
David Lawrence Ramsey
384332d08c display: make PageUp/PageDown use the correct beginning of the viewport
When typing PageUp or PageDOwn in non-smooth-scrolling mode, the cursor
should be placed at the start of the top line of the edit window.  This
means that, when the line at edittop is partially scrolled offscreen,
the cursor should be placed at openfile->firstcolumn, not at zero.

This fixes https://savannah.gnu.org/bugs/?50645.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-27 11:19:44 +02:00
David Lawrence Ramsey
6b1ad96f34 docs: update README.GIT for gnulib-related changes 2017-03-26 12:54:57 +02:00
David Lawrence Ramsey
0276e45465 configure: don't check for the existence of iswspace() anymore
The iswspace() was only used when iswblank() was missing.  The latter
is now provided by gnulib, so it is always available, so iswspace()
is not used at all anymore.
2017-03-26 12:50:33 +02:00
Benno Schulenberg
42ae3e377f docs: mention some more differences with Pico in the Info document
Mention the ability to use <Tab> in the search history, the ability
to restore the cursor position when reopening a file, the ability to
read output of a command, and the lack of file-managing commands in
the file browser.
2017-03-26 12:41:44 +02:00
Benno Schulenberg
58faff50ae tweaks: shorten a bit of logic 2017-03-24 21:37:06 +01:00
David Lawrence Ramsey
87a7c2e42d tweaks: fix a comment typo 2017-03-24 21:21:51 +01:00
David Lawrence Ramsey
f4ee83a76d syntax: nanorc: color also the option "linenumbers" as being valid 2017-03-24 21:18:17 +01:00
Benno Schulenberg
59412b572f files: on second thought... keep the "[from ./]"
The "./" is a shorthand for "current working directory".
It is better to specify it, because it differs from what
Pico does: reading always from the user's home directory
no matter where the editor was started.
2017-03-24 12:19:30 +01:00
Benno Schulenberg
261b5b28c4 tweaks: gettextize a forgotten error message 2017-03-23 22:12:27 +01:00
Benno Schulenberg
f987508891 files: drop the pointless "[from ./]" from the insert-file prompt
Only use the "from" thing when an operating directory is in effect,
because /only/ then the indicated directory can be something other
than "./".

Also, make it so that there is no space before the colon.
2017-03-23 22:10:47 +01:00
Benno Schulenberg
19b7021076 tweaks: suggest a separate color scheme for root
And slightly change the existing one for normal users.
2017-03-23 19:28:33 +01:00
Benno Schulenberg
9e7e88e157 bindings: accept "q" and "x" to exit from help viewer and file browser
"Q" is a pretty standard key to exit from something, and "X" is fairly
mnemonic -- better than "E" at least.
2017-03-23 12:42:53 +01:00
Benno Schulenberg
c01d6a8f74 tweaks: reshuffle the bindings to group things more logically
Put all the movement keys together, in order of ascending stride.

Also, move the Undo/Redo keystrokes further up, so that, when the
user has a somewhat wider terminal than the usual 80 characters,
these keystrokes will be shown -- they are far more interesting
than the ^Y and ^V ones, for which PgUp and PgDn can be used.
2017-03-23 11:37:36 +01:00
Benno Schulenberg
e46c6c9607 tweaks: ehm... the warning is more important for the softwrap case
But apparently none of these cases occur, because I can't trigger them.
2017-03-22 11:05:22 +01:00
Benno Schulenberg
8b7bbebeeb tweaks: add a warning for a condition that should never occur 2017-03-22 10:50:59 +01:00
Benno Schulenberg
55159b7b39 painting: don't try to start highlighting before column zero
This could happen when a tab or a double-width character straddles
the boundary between two softwrapped chunks.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
0389a1d939 softwrap: adjust firstcolumn when the window width changes
If the number of columns in the edit window changes (which currently
only happens in two places: in regenerate_screen(), called when the
window is resized; and in main(), when line numbering mode is toggled),
the display will break if we're in softwrap mode and firstcolumn is
nonzero.  This is because the column width of softwrapped chunks has
changed, and firstcolumn is no longer the starting column of a chunk,
an assumption that all code using firstcolumn relies on.

To fix this problem, add a new function, ensure_firstcolumn_is_aligned(),
to adjust firstcolumn to the starting column of the chunk it's on, and
use it when the number of columns in the edit window changes.

(Note that this function uses the simplest possible fix, and could
probably be made more sophisticated.)
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
c1f70185ba softwrap: save and restore firstcolumn when replacing text
In do_replace(), replacing text may change firstcolumn if the next match
is offscreen, and replacing text after that will not change it back.  In
order to keep the viewport unchanged, we have to save and restore not
just edittop, but firstcolumn as well.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
c888edf409 softwrap: save and restore firstcolumn when internally spell-fixing text
In do_int_spell_fix(), spell-checking text may change firstcolumn if
the next match is offscreen, and spell-checking text after that will
not change it back.  In order to keep the viewport unchanged, we have
to save and restore not just edittop, but firstcolumn as well.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
7cd50b8c02 softwrap: save firstcolumn when justifying, restore it when unjustifying
In do_justify(), justifying text may change firstcolumn if the paragraph
ends offscreen, and unjustifying the text again will not change it back.
In order to keep the viewport unchanged, we have to save and restore not
just edittop, but firstcolumn as well.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
6f0ed2075c softwrap: save and restore firstcolumn when copying text
Copying text involves first cutting it and then quickly pasting it back.
However, cutting the text may change firstcolumn if the mark is offscreen.
To keep the viewport unchanged, copy_text() has to save and restore not
just edittop, but firstcolumn as well.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
dd08b638c1 softwrap: account for softwrapped chunks when adding text
Now that we can add text to the bottom right corner of the screen
without scrolling the full line onscreen, do_output() needs to refresh
the screen in that case, since it would put the cursor offscreen
otherwise.  Accomplish this by borrowing logic from do_right().
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
93152d3258 softwrap: account for firstcolumn when scrolling up a line
In do_up() when scroll_only is TRUE, if we're at the top of the screen
in softwrap mode, it's not enough to check that edittop is on fileage.
We also need to check that firstcolumn is zero.

In do_up() when scroll_only is FALSE, if we're at the top of the screen
in softwrap mode, current_y should be zero.  This is equivalent to how,
in do_down() when scroll_only is FALSE, current_y is (editwinrows - 1)
at the bottom of the screen in softwrap mode.  Since edittop can now
be partially scrolled off the screen even when it takes up the entire
screen, checking for edittop's being equal to openfile->current->next
there no longer applies.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
2f6c8987ea softwrap: move the updating of a softwrapped line to a new function
The new function, update_softwrapped_line(), is called from inside
update_line() when softwrap mode is on, so that existing calls remain
unchanged.  It takes no index, instead displaying edittop from column
firstcolumn, and all other lines from column zero.

If current is on edittop, it's displayed using the edittop rules, but
this is not a problem: if current[current_x] is above edittop at column
firstcolumn, it's offscreen, and that should be handled before calling
update_line() anyway.

Together with the preceding bunch of changes,
this fixes https://savannah.gnu.org/bugs/?47667.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
98b029cf3e softwrap: account for firstcolumn in reset_cursor()
When counting rows in softwrap mode, reset_cursor() should compensate for
the number of softwrapped chunks that edittop takes up before firstcolumn.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
c0fa3f04b1 softwrap: account for firstcolumn when checking for offscreen current
Make current_is_above_screen() check for current[current_x] being above
edittop at column firstcolumn, and make current_is_below_screen() start
counting down from edittop at column firstcolumn instead of edittop at
column zero.  This means that both functions now account for softwrapped
chunks properly.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
e52d5b0672 softwrap: remove and replace workarounds for firstcolumn
Actually enable scrolling edittop partially off the screen by making
edit_scroll() and adjust_viewport() use firstcolumn properly when
iterating through softwrapped chunks in softwrap mode, or lines in
non-softwrap mode.

In non-softwrap mode, firstcolumn should still always be zero, because
it's initially set to that, and because passing it through the iterators
will maintain it at that.

This fixes https://savannah.gnu.org/bugs/?49100.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
4144f76e19 softwrap: prepare for a more flexible viewport
We want to be able to scroll the line at edittop partially off the
screen.  For this to be possible, the new variable firstcolumn stores
the starting column of the viewport -- the starting column in the line
that edittop points to.

Since firstcolumn is used by go_back_chunks() and go_forward_chunks(),
it can't be completely #ifdefed out when NANO_TINY is set, but outside
of softwrap mode it should always be zero.

Currently firstcolumn is initialized to zero, reset to zero when
toggling softwrap mode off, and reset to zero when switching buffers
while softwrap mode is off.  It's otherwise unused, but its uses are
forthcoming.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
80b3a3011b weeding: remove ensure_line_is_visible()
Since all lines can be partially scrolled off the screen now
(except for the top line of the edit window, which is forthcoming),
ensure_line_is_visible() is no longer needed.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
812ecaeb0c weeding: remove maxlines and related code
Since all lines can be partially scrolled off the screen now
(except for edittop, which is forthcoming), the maxlines global
variable and its computation mechanism are no longer needed.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
d0c3084eb5 softwrap: improve PageUp and PageDown's behavior with softwrapped chunks
Use go_back_chunks() and go_forward_chunks() to move a screenful of
lines or chunks up or down, instead of using special computations in
the softwrap case.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
eb647dfb44 softwrap: improve Up and Down's behavior with softwrapped chunks
Use go_back_chunks() and go_forward_chunks() in do_up() and do_down()
(instead of using a special and complicated computation in do_down())
so that they now properly move vertically to the previous/next chunk
in softwrap mode.  This also means that do_left() and do_right() will
now properly move vertically at actual line boundaries.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
56402e7589 softwrap: improve Left and Right's behavior with softwrapped chunks
Use the new "unclever" functionality of Home and End to make do_left()
and do_right() move properly to the end of the previous chunk or to the
start of the next chunk in softwrap mode when crossing a line boundary.
(Furthermore, doing Up plus End, or Down plus Home, does all needed
screen updates, which simplifies the code.)

The do_left() and do_right() functions don't yet properly move vertically
at line boundaries, but that will be fixed once do_up() and do_down() are
updated for softwrap mode, which is forthcoming.

This fixes https://savannah.gnu.org/bugs/?49384.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
a5e106d764 tweaks: add a parameter to do_home() and do_end()
Add the parameter be_clever to both functions.  When be_clever is FALSE,
smart home and dynamic home are disabled in do_home(), and dynamic end is
disabled in do_end(), so that these functions only move to the beginning
or end of the current line or chunk.

This simple home and end functionality is needed to improve do_left()
and do_right()'s horizontal behavior with softwrapped chunks, which is
forthcoming.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
e478682c55 softwrap: improve End's behavior with softwrapped chunks
Make do_end() more useful in softwrap mode: let it move to the end of the
current chunk instead of the end of the line; only when already at the end
of a chunk, let it move to the end of the line.  This is "dynamic end".
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
bd2d0863d6 softwrap: improve Home's behavior with softwrapped lines
Make do_home() more useful in softwrap mode: let it move to the beginning
of the current chunk instead of to the beginning of the whole line; only
when already at the beginning of a chunk, let it move to the beginning of
the line.  This is called "dynamic home'.

The above rules are ignored when --smarthome is in effect and the cursor
is somewhere in the leading whitespace of a line -- then the cursor is
moved to the first non-whitespace character of the line.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
d8189703b1 tweaks: prepare for improvements to do_home() and do_end()
These improvements will eventually make do_home() and do_end() take
parameters.  Since the global function lists can hold only functions
without parameters, preemptively add do_home_void() and do_end_void(),
and make the global function lists use them.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
52087408ef softwrap: iterate through softwrapped chunks better in do_mouse()
Use go_back_chunks() and go_forward_chunks() to move from the row
current_y is on to the row mouse_row is on.  Now softwrap mode and
non-softwrap mode will behave the same way when we can scroll edittop
partially off the screen, which is forthcoming.  Accordingly, remove
the call to ensure_line_is_visible(), as it no longer applies.

The old code did work, but it behaved differently between softwrap mode
(which counted down from edittop) and non-softwrap mode (which counted
up or down from current_y to take less time, and used a double loop to
keep current from going to NULL).

The new code counts up or down from current_y in both softwrap mode and
non-softwrap mode.  In non-softwrap mode, it also avoids the double loop,
since go_back_chunks() and go_forward_chunks() keep the filestructs they
operate on from going to NULL.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
2abf7b755b softwrap: iterate through softwrapped chunks in adjust_viewport()
Use go_back_chunks() to adjust edittop, instead of special casing
the computation of goal when softwrapping.  Now softwrap mode and
non-softwrap mode will behave the same way when edittop can be
partially scrolled off the screen, which is forthcoming.

(Note that the top line of the screen can't be partially scrolled
yet, so we have to work around that for now.)
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
ba4858de83 softwrap: iterate through softwrapped chunks in edit_scroll()
Use go_back_chunks() and go_forward_chunks() to adjust edittop and to
move up or down to the scrolled region before updating the rows there.
Now softwrap mode and non-softwrap mode will behave the same way when
we can scroll the top line of the screen partially off the screen,
which is forthcoming.

(Note that the top line of the screen can't be partially scrolled yet,
so we have to work around that for now.)
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
fa025f0ca3 display: limit an optimization to non-softwrap mode
Not drawing a line on a row if we're on the top row and scrolled down,
or if we're on the bottom row and scrolled up, will only work properly
if the line on that row takes up only that row.  The latter might not
be the case in softwrap mode: if the line occupies multiple chunks and
begins on that row -- in that case none of the chunks would be drawn.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
eb369c0e00 tweaks: rename need_horizontal_scroll() to line_needs_update()
The old name made it sound as if it didn't apply in softwrap mode.  But
it does: in softwrap mode a line needs updating  when the mark is on.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
df2a4679d5 softwrap: account for softwrap in get_page_start()
In softwrap mode, nano doesn't horizontally scroll lines at all, so in
this case get_page_start() should always return zero.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
380ad30a53 softwrap: account for softwrap when checking whether current is offscreen
Add the new functions current_is_above_screen() (which doesn't account
for softwrapped chunks yet, but will when we can scroll edittop partially
off the screen, which is forthcoming), current_is_below_screen() (which
determines whether current[current_x] is past the softwrapped chunk at
the bottom of the screen), and current_is_offscreen() (the union of the
previous two functions).

edit_redraw() and edit_refresh() now use current_is_offscreen() to check
whether they should adjust the viewport, and adjust_viewport() now uses
current_is_above_screen() to determine whether current is on or below
the screen in FLOWING mode.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
fd82989e29 softwrap: count softwrapped chunks properly in read_file()
Use less_than_a_screenful() again, just as in do_uncut_text().
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
4f9c563e6b softwrap: count softwrapped chunks properly in do_uncut_text()
Add the new function less_than_a_screenful() to accomplish this.
It uses go_back_chunks() to count the number of softwrapped chunks
between the end point and the starting point of the paste.

Now softwrap mode and non-softwrap mode behave the same way when
uncutting fewer than editwinrows rows of text.  Accordingly, remove
the call to ensure_line_is_visible(), as it no longer applies.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
1570651e30 softwrap: count softwrapped chunks properly in do_gotolinecolumn()
Use go_forward_chunks() to count softwrapped chunks between the current
cursor position and the bottom of the file.  Now softwrap mode and
non-softwrap mode behave the same way when moving to a line and column
non-interactively, instead of the former's always centering the screen.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
456d66b904 softwrap: add two chunk-iterator functions
These functions, go_back_chunks() and go_forward_chunks(), take a number
of softwrapped chunks (screen rows) to move, a pointer to a buffer, and
a location (specifically, a starting column of a softwrapped chunk).  If
they move successfully, they will update the buffer pointer and location
to point to the beginning of the softwrapped chunk they moved to.

Since non-softwrap mode is effectively just a subset of softwrap mode
in which every line takes up one chunk, these functions also work in
non-softwrap mode.  In this case, their starting column will always be
zero, as it would be in softwrap mode on a line that takes up one chunk.

Nothing uses these functions yet, but that is forthcoming.
2017-03-22 10:44:04 +01:00
Benno Schulenberg
da62ef8a43 tweaks: correct some formatting irregularities in the FAQ
And modify a few wordings too.
2017-03-20 20:33:47 +01:00
Benno Schulenberg
9b336a9d66 bindings: group the three search-again shortcuts together 2017-03-20 15:59:41 +01:00
Benno Schulenberg
d42f71a2ef tweaks: avoid a few needless reallocations
Most of these variables are freed moments later -- reallocating
them is thus a waste of time.
2017-03-20 13:07:57 +01:00
Benno Schulenberg
f48e15f2a3 tweaks: rename and shorten a small helper function 2017-03-20 12:24:42 +01:00
Benno Schulenberg
6d873d3760 startup: add option 'nopauses' to disable pausing after a warning
This addresses a followup of https://savannah.gnu.org/bugs/?50362.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-03-16 19:26:39 +01:00
Mike Frysinger
85a8e5cfd2 tweaks: disable gnulib's workaround for the globbing of broken symlinks
Our use of globbing (for syntax files) doesn't care about such symlinks.

This avoids an unnecessary increase in size of eight kilobytes -- see
https://lists.gnu.org/archive/html/nano-devel/2017-03/msg00036.html.
2017-03-14 21:28:21 +01:00
Benno Schulenberg
5283acdcf3 tweaks: trim a displayable string in a more efficient manner
Instead of redetermining the entire span of the converted string,
simply move one character left, and then bite it off to make place
for the trailing $.
2017-03-14 21:20:50 +01:00
Mike Frysinger
0d9a734724 pull in the nl_langinfo & wcwidth modules from gnulib
These functions aren't available on mingw toolchains, so include the
gnulib modules so we can fall back on them.
2017-03-09 14:37:57 +01:00
Benno Schulenberg
69784d51db screen: don't push the longer-line indicator ($) to the next row
If the last two columns of a row would be taken up by a double-width
character (and the line is longer than that), don't print it, because
it wouldn't leave any room for the $ character.

This fixes https://savannah.gnu.org/bugs/?50491.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-08 21:24:13 +01:00
David Lawrence Ramsey
3c3eb4909d usage: mention the -g/--showcursor option
It's already in the external documentation; it should be here as well.
2017-03-06 21:09:59 +01:00
Hans-Bernhard Broeker
636b7348a6 tweaks: make sure calls to <ctype.h> functions/macros use "unsigned char"
The platform's default char type might be signed, which could cause
problems in 8-bit locales.

This addresses https://savannah.gnu.org/bugs/?50289.
Reported-by: Hans-Bernhard Broeker <HBBroeker@T-Online.de>
2017-03-06 20:58:25 +01:00
Mike Frysinger
0176cb5b30 pull in the sys_wait module from gnulib
This is used by systems that lack sys/wait.h, like Windows.
2017-03-06 12:02:32 +01:00
Mike Frysinger
ca86045918 handle builds on systems without termios.h
Windows doesn't have this, so add some build time checks.
2017-03-06 12:02:28 +01:00
Mike Frysinger
cab33779ae handle deficient signal systems
Pull in the sigaction module from gnulib, and add ifdef checks
for a bunch of signals that don't exist on Windows.
2017-03-06 12:02:25 +01:00
Mike Frysinger
7c2cfd6e0c pull in the lstat module from gnulib
This is used by systems that lack lstat(), like Windows.
2017-03-06 12:02:20 +01:00
Mike Frysinger
a8deac5845 add an explicit test for set_escdelay()
Not all curses implementations provide this function, so drop it
from depending on slang (and assuming ncurses) to a general build
time test.
2017-03-06 12:02:16 +01:00
Mike Frysinger
a9a45f2b55 fix build on systems without pwd.h
Windows doesn't have *nix style account databases.
2017-03-06 12:02:09 +01:00
Mike Frysinger
a0fb55235a pull in the glob module from gnulib
This is used by systems that lack glob.h, like Windows.
2017-03-06 12:02:06 +01:00
Mike Frysinger
e7c43521fc drop the wchar.h/wctype.h/stdarg.h checks
Since gnulib provides these now, we can assume them.
2017-03-06 12:01:21 +01:00
Mike Frysinger
9a2deb4182 drop the glib fallback for snprintf/vsnprintf
The gnulib imports handle this for us now.
2017-03-06 12:01:17 +01:00
Mike Frysinger
272345ccf9 assume getopt_long support is always available
Now that we pull in the gnulib getopt-gnu module, we can assume it exists.
2017-03-06 12:01:12 +01:00
Mike Frysinger
3deec4352b assume regex.h support is always available
Now that we pull in the gnulib regex module, we can assume it exists.
2017-03-06 12:01:08 +01:00
Mike Frysinger
63cae0c199 drop the isblank/iswblank fallback functions
Switch over to gnulib for these.
2017-03-06 12:01:05 +01:00
Mike Frysinger
e9a3f858bc drop the getdelim/getline fallback functions
Switch over to gnulib for these.
2017-03-06 12:01:02 +01:00
Mike Frysinger
28133e934d drop various str fallback functions
These are provided by gnulib now.
2017-03-06 12:00:57 +01:00
Mike Frysinger
ba8d71f447 add support for gnulib
On a system with up-to-date GNU tools, this does not change
the size of nano's binary.

We start off with importing only a few modules, although we
don't yet delete the fallback logic for them.
2017-03-06 11:56:02 +01:00
Mike Frysinger
9d0331dea2 configure: require gettext-0.18.3, and drop our bundled m4 files
The gettext-0.18.3 release was made in Jul 2013, while the 0.11.5
release was made in Aug 2002.  Time to update :).

Also drop all the bundled gettext m4 files.  When you run autogen.sh,
these will get copied in automatically for you.
2017-03-06 11:52:16 +01:00
Mike Frysinger
c04a8ce654 configure: require autoconf-2.69/automake-1.14
The autoconf-2.69 release was made in Apr 2012.
The automake-1.14 release was made in Jun 2013.

Update the requirements so we know we can rely on macros/features
available in those versions.
2017-03-06 11:52:04 +01:00
Benno Schulenberg
83a841cd06 tweaks: chuck some debugging stuff and some useless asserts 2017-03-01 13:56:08 +01:00
Benno Schulenberg
0af5788a94 tweaks: reduce the scope of five variables, and frob some comments 2017-03-01 09:56:38 +01:00
Benno Schulenberg
d5b950cc29 tweaks: don't turn the mark off before it's needed
The mark only needs to be off when calling replace_marked_buffer(),
because this indirectly calls ingraft_buffer(), which fiddles with
the end points if the mark is on.
2017-03-01 09:35:45 +01:00
Benno Schulenberg
adf69a05f1 spelling: keep the cursor at end-of-line if it was there
This fixes https://savannah.gnu.org/bugs/?50415.
2017-02-28 20:45:49 +01:00
Benno Schulenberg
355a07bbce tweaks: don't optimize for the wrong case
Running strlenpt() on a string that takes up more than 80 columns
(the width of an average terminal) takes /more/ time than simply
converting an extra character (the one that will be overwritten
by the "$" at the edge of the terminal).  So... just convert one
more character than necessary when the line is overlong.  In the
most common case, however, the line will fit fully onscreen, and
we save a whole call of strlenpt().
2017-02-28 17:07:38 +01:00
David Lawrence Ramsey
0404474ec2 tweaks: stop converting text once we overshoot span columns
Since we only need span columns of the string, stop scanning the string
as soon as we have that many columns, instead of scanning the string all
the way to the end.  This speeds up the conversion of very long lines.
2017-02-28 16:50:22 +01:00
Benno Schulenberg
a80ade38d7 tweaks: rename two variables, to be more distinctive 2017-02-28 15:17:03 +01:00
Benno Schulenberg
48643cbdf3 tweaks: elide a small intermediate buffer 2017-02-28 15:05:02 +01:00
Benno Schulenberg
aa013aa007 tweaks: elide a variable 2017-02-28 14:53:10 +01:00
Benno Schulenberg
91910b2364 input: count a manually entered unicode as one character
This fixes https://savannah.gnu.org/bugs/?50403.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-28 14:47:45 +01:00
David Lawrence Ramsey
29681e0e9f weeding: remove partitioning and related stuff from do_justify()
Replace partitioning with calls to extract_buffer() and ingraft_buffer().

In addition to pasting the unjustified text back into the buffer at
current[current_x], ingraft_buffer() also deals with renumbering and
updating totsize, so do_justify() doesn't need to do those anymore
when unjustifying.
2017-02-28 14:35:44 +01:00
David Lawrence Ramsey
234bd9c9be speller: fix replacing marked text in the alternate spell checker
With read_file() revamped, it now uses partition_filestruct() indirectly
via ingraft_buffer(), so we can't use partition_filestruct() to replace
marked text in the alternate spell checker anymore without segfaulting.

Add the new function replace_marked_buffer() to accomplish this instead.
Based on replace_buffer(), it uses extract_buffer() to throw away the
marked un-spell-checked text, and then uses read_file() to insert the
spell-checked text at the position where the mark was.

Accordingly, remove unneeded partitioning and related stuff from
do_alt_speller().  Besides pasting the file into the buffer at
current[current_x], ingraft_buffer() also deals with renumbering,
updating totsize, and handling a magicline, so do_alt_speller()
doesn't need to do those anymore.
2017-02-28 14:35:44 +01:00
David Lawrence Ramsey
0d9313763d undo: fix undoing/redoing insertions, since they no longer do partitioning 2017-02-28 14:35:44 +01:00
David Lawrence Ramsey
ef43ebfef4 weeding: remove partitioning and related stuff from do_insertfile()
With read_file() revamped to handle inserting a file at the current
position, partitioning the buffer is no longer needed.
2017-02-28 14:35:44 +01:00
David Lawrence Ramsey
86f7bc1868 files: revamp the insertion of a file, to be more like pasting text
Move buffer handling and '\r' stripping from read_line() to read_file(),
so that the file gets its format determined and gets stored in its own
buffer entirely in one function.  Then use ingraft_buffer() to insert
this new buffer into the current one.

In addition to pasting the file at current[current_x], ingraft_buffer()
also deals with renumbering, the updating of totsize, and the handling
of a magicline, so read_file() doesn't need to do those anymore.

Note that all this makes read_file() depend on the position of
current[current_x] to know where to insert the file.  Accordingly,
set current_x to zero in initialize_buffer_text() instead of in
make_new_buffer(), so that replace_buffer() keeps working properly.
2017-02-28 14:35:44 +01:00
Benno Schulenberg
3d9a4d6257 tweaks: make WhereIsNext available in browser in tiny version
Also, avoid a warning with with --enable-tiny --enable-browser.
2017-02-27 19:22:50 +01:00
Benno Schulenberg
eb67af9347 tweaks: fix compilation with --enable-tiny --enable-help 2017-02-27 19:10:39 +01:00
Benno Schulenberg
efdd73922e oops -- that's what you get when you don't test things before pushing
Of course 'row' needs to be initialized to zero for the softwrap case.
2017-02-26 18:29:18 +01:00
Benno Schulenberg
2e53ed2928 tweaks: use two extra variables to make it clearer what is being done
This addresses https://savannah.gnu.org/patch/?9215.
Inspired-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-26 17:33:10 +01:00
Benno Schulenberg
59e10bdef2 usage: don't mention +LINE,COLUMN as an option, because it isn't
Add its explanation as a separate paragraph.

Also: improve the argument of the --syntax option, as this is a <name>
and not merely a bundle of characters like the other <str> arguments.
2017-02-25 14:05:07 +01:00
David Lawrence Ramsey
6eefad4fff tweaks: mention nano's ability to read from standard input in usage() 2017-02-25 14:00:27 +01:00
Benno Schulenberg
e5731fe198 tweaks: reshuffle three statements, and shorten a comment 2017-02-25 12:33:01 +01:00
Benno Schulenberg
2bbb6cfeb5 wrapping: add the correct char length when skipping consecutive blanks
In this last loop of break_line(), the pointer 'line' is one step ahead
of the index 'lastblank'.  So the loop should first add the length of
the preceding character to 'lastblank' before determining the length
of the current character (and using this to advance 'line').
2017-02-25 11:18:24 +01:00
Benno Schulenberg
1623bc7779 tweaks: rename three variables, to better distinguish bytes from columns
(There is something wrong in the last loop: line is one character ahead
of lastblank, but the current character length is added to both of them.
It thus assumes that all blank characters are the same number of bytes.
For spaces and tabs this works fine.  But for more exotic blanks...)
2017-02-24 22:08:55 +01:00
Benno Schulenberg
99ecd33c18 tweaks: elide two variables, and condense some statements
Also, remove an assert and adjust some comments.
2017-02-24 21:11:37 +01:00
David Lawrence Ramsey
6500f769aa tweaks: move comments outside of if blocks in break_line() 2017-02-24 21:04:31 +01:00
David Lawrence Ramsey
f95836a951 tweaks: remove cluttering #ifdefs from break_line()
Also, rename a parameter to be less cryptic, and remove an entire
condition because the relevant block will never be reached when
getting called from the help routines: if blank_loc is negative,
the function will have bailed out in the preceding if.
2017-02-24 17:33:39 +01:00
Benno Schulenberg
0378146add tweaks: rename a variable, drop a false assert, and reshuffle a bit 2017-02-24 15:07:04 +01:00
David Lawrence Ramsey
6e9d6a08b9 replacing: fix spotlight() to highlight words properly in softwrap mode
In softwrap mode, the entire line is onscreen, so the word is never
partially offscreen, so we always have enough columns to show it.

This fixes https://savannah.gnu.org/bugs/?50389.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-24 15:06:44 +01:00
Benno Schulenberg
07ebba5e99 tweaks: rename a variable and invert its logic 2017-02-24 12:21:59 +01:00
Benno Schulenberg
9e6e1ebe58 tweaks: remove a disabled warning, and adjust a translator hint 2017-02-24 12:06:15 +01:00
Benno Schulenberg
d365ca80bf tweaks: optimize determining the number of columns that a text spans
Give the strlenpt() routine its own implementation, so that it avoids
a needless comparison plus subtraction in the inner loop.
2017-02-24 11:01:24 +01:00
David Lawrence Ramsey
f1d214c0ef tweaks: slightly optimize an allocation in display_string()
Instead of allocating enough space to convert the entire passed string,
just allocate space for converting the part that will be converted --
that is: starting from start_index.  This still allocates far too much
(if the passed string is very long and its tail part won't fit on the
screen), but it's better than before.
2017-02-24 10:52:04 +01:00
Benno Schulenberg
1d3f3a6e25 tweaks: mark a message for translation 2017-02-23 15:22:07 +01:00
86 changed files with 22303 additions and 23411 deletions

42
.gitignore vendored
View File

@@ -16,6 +16,7 @@ core
/ABOUT-NLS
/INSTALL
/aclocal.m4
/ar-lib
/autom4te.cache
/compile
/config.cache
@@ -34,6 +35,47 @@ core
/mkinstalldirs
/stamp-h1
# gettext m4 files.
/m4/codeset.m4
/m4/extern-inline.m4
/m4/fcntl-o.m4
/m4/gettext.m4
/m4/glibc2.m4
/m4/glibc21.m4
/m4/iconv.m4
/m4/intdiv0.m4
/m4/intl.m4
/m4/intldir.m4
/m4/intlmacosx.m4
/m4/intmax.m4
/m4/inttypes-pri.m4
/m4/inttypes_h.m4
/m4/lcmessage.m4
/m4/lib-ld.m4
/m4/lib-link.m4
/m4/lib-prefix.m4
/m4/lock.m4
/m4/longlong.m4
/m4/nls.m4
/m4/po.m4
/m4/printf-posix.m4
/m4/progtest.m4
/m4/size_max.m4
/m4/stdint_h.m4
/m4/threadlib.m4
/m4/uintmax_t.m4
/m4/visibility.m4
/m4/wchar_t.m4
/m4/wint_t.m4
/m4/xsize.m4
# gnulib entries
/gnulib/
/lib/
/m4/.gitignore
/m4/gnulib-cache.m4
/snippet/
/nano.spec
/src/nano
/src/revision.h

140
ChangeLog
View File

@@ -1,3 +1,143 @@
Changes between v2.7.5 and v2.8.0:
----------------------------------
Benno Schulenberg (56):
bindings: accept "q" and "x" to exit from help viewer and file browser
bindings: group the three search-again shortcuts together
bump version numbers and add a news item for the 2.8.0 release
docs: mention some more differences with Pico in the Info document
files: drop the pointless "[from ./]" from the insert-file prompt
files: on second thought... keep the "[from ./]"
input: count a manually entered unicode as one character
moving: don't try to redraw lines that have gone outside the viewport
moving: /do/ redraw the prior line when the viewport hasn't changed
moving: the current chunk cannot be beyond the last chunk of a line
oops -- that's what you get when you don't test things before pushing
painting: don't try to start highlighting before column zero
screen: don't push the longer-line indicator ($) to the next row
spelling: keep the cursor at end-of-line if it was there
startup: add option 'nopauses' to disable pausing after a warning
tweaks: add a warning for a condition that should never occur
tweaks: avoid a few needless reallocations
tweaks: chuck some debugging stuff and some useless asserts
tweaks: condense some declarations by reshuffling
tweaks: correct some formatting irregularities in the FAQ
tweaks: don't loop over an initializer
tweaks: don't optimize for the wrong case
tweaks: don't turn the mark off before it's needed
tweaks: ehm... the warning is more important for the softwrap case
tweaks: elide an intermediate variable
tweaks: elide a small intermediate buffer
tweaks: elide a variable
tweaks: elide two variables, and condense some statements
tweaks: factor out a bit of common code
tweaks: fix compilation with --enable-tiny --enable-help
tweaks: frob a couple of comments
tweaks: frob some parentheses and other things, to be more consistent
tweaks: gettextize a forgotten error message
tweaks: make WhereIsNext available in browser in tiny version
tweaks: mark a message for translation
tweaks: optimize determining the number of columns that a text spans
tweaks: reduce the scope of five variables, and frob some comments
tweaks: remove a disabled warning, and adjust a translator hint
tweaks: rename and shorten a small helper function
tweaks: rename a variable and invert its logic
tweaks: rename a variable, drop a false assert, and reshuffle a bit
tweaks: rename three variables, to better distinguish bytes from columns
tweaks: rename two variables, to be more distinctive
tweaks: reshuffle some lines and adjust some comments
tweaks: reshuffle some more lines and improve four comments
tweaks: reshuffle some statements, to avoid double assignments
tweaks: reshuffle the bindings to group things more logically
tweaks: reshuffle three statements, and shorten a comment
tweaks: reshuffle two declarations for a more consistent order
tweaks: shorten a bit of logic
tweaks: simplify and correct a computation
tweaks: suggest a separate color scheme for root
tweaks: trim a displayable string in a more efficient manner
tweaks: use two extra variables to make it clearer what is being done
usage: don't mention +LINE,COLUMN as an option, because it isn't
wrapping: add the correct char length when skipping consecutive blanks
David Lawrence Ramsey (52):
configure: don't check for the existence of iswspace() anymore
display: don't compensate for chunks before firstcolumn
display: don't draw more chunks than the screen can hold
display: limit an optimization to non-softwrap mode
display: make PageUp/PageDown use the correct beginning of the viewport
docs: update README.GIT for gnulib-related changes
files: revamp the insertion of a file, to be more like pasting text
moving: determine the correct leftedge when paging up/down too
replacing: fix spotlight() to highlight words properly in softwrap mode
softwrap: account for firstcolumn in reset_cursor()
softwrap: account for firstcolumn when checking for offscreen current
softwrap: account for firstcolumn when scrolling up a line
softwrap: account for softwrap in get_page_start()
softwrap: account for softwrapped chunks when adding text
softwrap: account for softwrap when checking whether current is offscreen
softwrap: add two chunk-iterator functions
softwrap: adjust firstcolumn when the window width changes
softwrap: count softwrapped chunks properly in do_gotolinecolumn()
softwrap: count softwrapped chunks properly in do_uncut_text()
softwrap: count softwrapped chunks properly in read_file()
softwrap: improve End's behavior with softwrapped chunks
softwrap: improve Home's behavior with softwrapped lines
softwrap: improve Left and Right's behavior with softwrapped chunks
softwrap: improve PageUp and PageDown's behavior with softwrapped chunks
softwrap: improve Up and Down's behavior with softwrapped chunks
softwrap: iterate through softwrapped chunks better in do_mouse()
softwrap: iterate through softwrapped chunks in adjust_viewport()
softwrap: iterate through softwrapped chunks in edit_scroll()
softwrap: move the updating of a softwrapped line to a new function
softwrap: prepare for a more flexible viewport
softwrap: remove and replace workarounds for firstcolumn
softwrap: save and restore firstcolumn when copying text
softwrap: save and restore firstcolumn when internally spell-fixing text
softwrap: save and restore firstcolumn when replacing text
softwrap: save firstcolumn when justifying, restore it when unjustifying
speller: fix replacing marked text in the alternate spell checker
syntax: nanorc: color also the option "linenumbers" as being valid
tweaks: add a parameter to do_home() and do_end()
tweaks: fix a comment typo
tweaks: mention nano's ability to read from standard input in usage()
tweaks: move comments outside of if blocks in break_line()
tweaks: prepare for improvements to do_home() and do_end()
tweaks: remove cluttering #ifdefs from break_line()
tweaks: rename need_horizontal_scroll() to line_needs_update()
tweaks: slightly optimize an allocation in display_string()
tweaks: stop converting text once we overshoot span columns
undo: fix undoing/redoing insertions, since they no longer do partitioning
usage: mention the -g/--showcursor option
weeding: remove ensure_line_is_visible()
weeding: remove maxlines and related code
weeding: remove partitioning and related stuff from do_insertfile()
weeding: remove partitioning and related stuff from do_justify()
Hans-Bernhard Broeker (1):
tweaks: make sure calls to <ctype.h> functions/macros use "unsigned char"
Mike Frysinger (19):
add an explicit test for set_escdelay()
add support for gnulib
assume getopt_long support is always available
assume regex.h support is always available
configure: require autoconf-2.69/automake-1.14
configure: require gettext-0.18.3, and drop our bundled m4 files
drop the getdelim/getline fallback functions
drop the glib fallback for snprintf/vsnprintf
drop the isblank/iswblank fallback functions
drop the wchar.h/wctype.h/stdarg.h checks
drop various str fallback functions
fix build on systems without pwd.h
handle builds on systems without termios.h
handle deficient signal systems
pull in the glob module from gnulib
pull in the lstat module from gnulib
pull in the nl_langinfo & wcwidth modules from gnulib
pull in the sys_wait module from gnulib
tweaks: disable gnulib's workaround for the globbing of broken symlinks
Changes between v2.7.4 and v2.7.5:
----------------------------------

View File

@@ -1,6 +1,6 @@
AUTOMAKE_OPTIONS = gnu no-dependencies
SUBDIRS = doc m4 po src
SUBDIRS = doc lib m4 po src
if USE_COLOR
SUBDIRS += syntax

16
NEWS
View File

@@ -1,3 +1,19 @@
2017.03.31 - GNU nano 2.8.0 "Axat" makes it easier to move around in
softwrapped lines: the Up and Down keys now step from
visual row to visual row instead of jumping between
logical lines, and the Home and End keys now move to
the start and end of a row, and only when already
there, then to the start and end of the logical line.
Furthermore, the screen can now scroll per row instead
of always per logical line. On an entirely different
front: nano now makes use of gnulib, to make it build
on more platforms. In short: there were many internal
changes, not many user-visible ones (apart form the
new softwrap navigation). The conversion to gnulib
was done by Mike Frysinger, the softwrap overhaul by
David Ramsey.
2017.02.23 - GNU nano 2.7.5 "Nijntje" can properly search and replace
the \B and \b regex anchors, correctly repaints things
when multiline regexes with identical start and end are

View File

@@ -11,10 +11,10 @@ Prerequisites
To successfully compile GNU nano from git, you'll need the following
packages:
- autoconf (version >= 2.61)
- automake (version >= 1.7)
- autopoint (version >= 0.11.5)
- gettext (version >= 0.11.5)
- autoconf (version >= 2.69)
- automake (version >= 1.14)
- autopoint (version >= 0.18.3)
- gettext (version >= 0.18.3)
- git (version >= 2.7.4)
- groff (version >= 1.12)
- pkg-config (version >= 0.22)
@@ -24,8 +24,6 @@ packages:
If you want UTF-8 support, you will also need libncursesw5-dev installed
(version >= 5.7), or libslang2-dev (version >= 2.0) if you use --with-slang.
If your system doesn't have 'snprintf' or 'vsnprintf' (which the configure
script will check for), you will also need glib-2.x installed.
These should all be available in your distro's package manager or software
center, or otherwise on any GNU mirror.

4
TODO
View File

@@ -8,9 +8,7 @@ Vague musings:
- Allow indentation of marked text by spaces as well as tabs?
- Allow indentation to add just enough columns to reach the nearest
multiple of tabsize, rather than always adding tabsize columns?
- Allow conversion between different character sets. Maybe use glib's
iconv() if the system's iconv() is inadequate, since we already use
glib's vsnprintf() if the system lacks vsnprintf()?
- Allow conversion between different character sets.
- Allow setting marks (saved positions, not to be confused with the mark
set via Ctrl-^) at various lines and/or columns in the buffer, and
allow movement between them with a single keystroke?

View File

@@ -1,4 +1,47 @@
#!/bin/sh
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="4084b3a1094372b960ce4a97634e08f4538c8bdd"
modules="
getdelim
getline
getopt-gnu
glob
isblank
iswblank
lstat
nl_langinfo
regex
sigaction
snprintf-posix
stdarg
strcase
strcasestr-simple
strnlen
sys_wait
vsnprintf-posix
wchar
wctype-h
wcwidth
"
# Make sure the local gnulib git repo is up-to-date.
if [ ! -d "gnulib" ]; then
git clone --depth=123 ${gnulib_url}
fi
cd gnulib >/dev/null || exit 1
curr_hash=$(git log -1 --format=%H)
if [ "${gnulib_hash}" != "${curr_hash}" ]; then
git pull
git checkout -f ${gnulib_hash}
fi
cd .. >/dev/null || exit 1
rm -rf lib
./gnulib/gnulib-tool \
--import \
${modules}
autoreconf -f -i -s

View File

@@ -16,20 +16,30 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
AC_INIT([GNU nano], [2.7.5], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [2.8.0], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE
AM_INIT_AUTOMAKE([1.14])
AC_CONFIG_HEADERS([config.h])
dnl Make sure the ONCE macros are available.
AC_PREREQ(2.61)
AC_PREREQ([2.69])
dnl Lie about gnulib features we don't use to speed up & shrink down.
gl_cv_func_printf_directive_n=yes
gl_cv_func_printf_infinite_long_double=yes
gl_cv_func_printf_long_double=yes
gl_cv_func_snprintf_directive_n=yes
gl_cv_glob_lists_symlinks=yes
dnl Checks for programs.
AC_GNU_SOURCE
AC_PROG_CC
gl_EARLY
gl_INIT
AC_PROG_LN_S
AC_ISC_POSIX
AC_SYS_LARGEFILE
@@ -37,7 +47,7 @@ PKG_PROG_PKG_CONFIG
dnl Internationalization macros.
AM_GNU_GETTEXT_VERSION(0.11.5)
AM_GNU_GETTEXT_VERSION([0.18.3])
AM_GNU_GETTEXT([external], [need-ngettext])
AM_CONDITIONAL(USE_NLS, test x$USE_NLS = xyes)
@@ -48,7 +58,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
dnl Checks for header files.
AC_CHECK_HEADERS(getopt.h libintl.h limits.h regex.h sys/param.h wchar.h wctype.h stdarg.h)
AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
dnl Checks for options.
@@ -71,15 +81,7 @@ fi
if test "x$enable_color" = xno; then
AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.])
else
if test x$ac_cv_header_regex_h != xyes; then
AC_MSG_ERROR([
*** The header file regex.h was not found. If you wish to have
*** color support, this header file is required. Please either
*** install C libraries that include the regex.h file, or call
*** the configure script with --disable-color.])
else
color_support=yes
fi
color_support=yes
fi
AC_ARG_ENABLE(comment,
@@ -467,30 +469,9 @@ int main(void)
dnl Checks for functions.
AC_CHECK_FUNCS(getdelim getline isblank strcasecmp strcasestr strncasecmp strnlen snprintf vsnprintf)
if test "x$enable_utf8" != xno; then
AC_CHECK_FUNCS(iswalnum iswblank iswpunct iswspace nl_langinfo mblen mbstowcs mbtowc wctomb wcwidth)
AC_CHECK_FUNCS(iswalnum iswpunct mblen mbstowcs mbtowc wctomb)
fi
if test x$ac_cv_func_snprintf = xno; then
AM_PATH_GLIB_2_0(2.0.0,,
AC_MSG_ERROR([
*** snprintf() not found. GLIB 2.x not found either.
*** You should install the GLIB 2.x library which can
*** be found at http://ftp.gtk.org/.]),
glib)
fi
if test x$ac_cv_func_vsnprintf = xno; then
AM_PATH_GLIB_2_0(2.0.0,,
AC_MSG_ERROR([
*** vsnprintf() not found. GLIB 2.x not found either.
*** You should install the GLIB 2.x library which can
*** be found at http://ftp.gtk.org/.]),
glib)
fi
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for available flags.
@@ -500,8 +481,6 @@ AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [], [])
dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(getopt_long)
dnl Checks for libraries.
@@ -568,6 +547,9 @@ fi
AC_CHECK_LIB([$CURSES_LIB_NAME], [use_default_colors],
[AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() command.])],
[], [$CURSES_LIB])
AC_CHECK_LIB([$CURSES_LIB_NAME], [set_escdelay],
[AC_DEFINE(HAVE_SET_ESCDELAY, 1, [Define this if your curses library has the set_escdelay() function.])],
[], [$CURSES_LIB])
AC_CHECK_LIB([$CURSES_LIB_NAME], [key_defined],
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() command.])],
[], [$CURSES_LIB])
@@ -578,25 +560,15 @@ LIBS="$LIBS $CURSES_LIB"
AC_SUBST(CURSES_LIB)
if test "x$GLIB_CFLAGS" != "x"; then
CFLAGS="$CFLAGS $GLIB_CFLAGS"
fi
if test "x$GLIB_LIBS" != "x"; then
LDFLAGS="$LDFLAGS $GLIB_LIBS"
fi
if test "x$enable_utf8" != xno && \
test x$CURSES_LIB_WIDE = xyes && \
test x$ac_cv_func_iswalnum = xyes && \
test x$ac_cv_func_iswpunct = xyes && \
(test x$ac_cv_func_iswblank = xyes || test x$ac_cv_func_iswspace = xyes) && \
test x$ac_cv_func_nl_langinfo = xyes && \
test x$ac_cv_func_mblen = xyes && \
test x$ac_cv_func_mbstowcs = xyes && \
test x$ac_cv_func_mbtowc = xyes && \
test x$ac_cv_func_wctomb = xyes && \
test x$ac_cv_func_wcwidth = xyes; then
AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), nl_langinfo, mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).])
test x$ac_cv_func_wctomb = xyes; then
AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support.])
else
if test "x$enable_utf8" = xyes; then
AC_MSG_ERROR([
@@ -747,6 +719,7 @@ AC_CONFIG_FILES([
Makefile
doc/Makefile
doc/sample.nanorc
lib/Makefile
m4/Makefile
po/Makefile.in
src/Makefile

View File

@@ -82,7 +82,7 @@
<h2><a name="1.5"></a>1.5. Why the name change from TIP?</h2>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h2><a name="1.6"></a>1.6. What is the current version of nano?</h2>
<blockquote><p>The current version of nano <i>should</i> be <b>2.7.5</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano <i>should</i> be <b>2.8.0</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h2><a name="1.7"></a>1.7. I want to read the man page without having to download the program!</h2>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
@@ -230,12 +230,13 @@
<h2><a name="6.1"></a>6.1. Why should I use nano instead of Pico?</h2>
<blockquote><p>There are many reasons to use nano instead of Pico. A more complete list can be found at the <a href="https://nano-editor.org/">nano homepage</a>.</p></blockquote>
<h2><a name="6.2"></a>6.2. Why should I use Pico instead of nano?</h2>
<blockquote><p>Again, check out the <a href="https://nano-editor.org/">nano homepage</a> for a good summary of reasons. It really is a matter of personal preference as to which editor you should use. If you're the type of person who likes using the original version of a program, then Pico is the editor for you. If you don't mind sacrificing mailer integration with Pine, and are looking for a few more features, as well as a 'better' license in terms of adding your own changes, nano is the way to go.</p><p>Note that the last of these no longer applies to the new version of Pine, <a href="http://www.washington.edu/alpine/">Alpine</a>, which is under the Apache License, version 2.0.</p></blockquote>
<blockquote><p>Again, check out the <a href="https://nano-editor.org/">nano homepage</a> for a good summary of reasons. It really is a matter of personal preference as to which editor you should use. If you're the type of person who likes using the original version of a program, then Pico is the editor for you. If you don't mind sacrificing mailer integration with Pine, and are looking for a few more features, as well as a 'better' license in terms of adding your own changes, nano is the way to go.</p>
<p>Note that the last of these no longer applies to the new version of Pine, <a href="http://www.washington.edu/alpine/">Alpine</a>, which is under the Apache License, version 2.0.</p></blockquote>
<h2><a name="6.3"></a>6.3. What is so bad about the older Pine license?</h2>
<blockquote><p>The U of W license for older versions of Pine and Pico is not considered truly Free Software according to both the Free Software Foundation and the <a href="http://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a>. The main problem regards the limitations on distributing derived works: according to UW, you can distribute their software, and you can modify it, but you can not do both, i.e. distribute modified binaries.</p></blockquote>
<h2><a name="6.4"></a>6.4. Okay, well, what mail program should I use then?</h2>
<blockquote><p>If you are looking to use a Free Software program similar to Pine, and Emacs is not your thing, you should definitely take a look at <a href="http://www.mutt.org/">mutt</a>. It is a full-screen, console based mail program that actually has a lot more flexibility than Pine, but has a keymap included in the distribution that allows you to use the same keystrokes as Pine would to send and receive mail. It's also under the GNU General Public License, version 2.0.<P>
Of course, due to the license change you can now use the <A HREF="http://www.washington.edu/alpine/">Alpine distribution</A> of PINE as it is now considered Free Software, but you would be sacrificing many of nano's features to do so.</p></blockquote>
<blockquote><p>If you are looking to use a Free Software program similar to Pine, and Emacs is not your thing, you should definitely take a look at <a href="http://www.mutt.org/">mutt</a>. It is a full-screen, console based mail program that actually has a lot more flexibility than Pine, but has a keymap included in the distribution that allows you to use the same keystrokes as Pine would to send and receive mail. It's also under the GNU General Public License, version 2.0.</p>
<p>Of course, due to the license change you can now use the <a href="http://www.washington.edu/alpine/">Alpine distribution</a> of PINE as it is now considered Free Software, but you would be sacrificing many of nano's features to do so.</p></blockquote>
<hr width="100%">
<h1><a name="7"></a>7. Miscellaneous</h1>
@@ -248,8 +249,8 @@ Of course, due to the license change you can now use the <A HREF="http://www.was
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="https://nano-editor.org/dist/latest/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<h2><a name="7.3"></a>7.3. How do I submit a bug report or patch?</h2>
<blockquote>
<p>The best place to submit bugs is to the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a> as you can check whether the bug you are submitting has already been submitted.
<p>Please submit patches for nano via the <a href="https://savannah.gnu.org/patch/?group=nano">Savannah project's patch manager</a> for the nano project.</p></blockquote>
<p>The best way to submit bugs is through the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a>, as you can check whether the bug you are reporting has already been submitted, and it makes it easier for the maintainers to keep track of them.
<p>You can submit patches for nano via <a href="https://savannah.gnu.org/patch/?group=nano">Savannah's patch manager</a>.</p></blockquote>
<h2><a name="7.4"></a>7.4. How do I join the development team?</h2>
<blockquote><p>The easiest way is to consistently send in good patches that add some needed functionality, fix a bug or two, and/or make the program more optimized/efficient. Then ask nicely and you will probably be added to the Savannah development list and be given write access after a while. There is a lot of responsibility that goes along with being a team member, so don't think it's just something to add to your resume.</p></blockquote>
<h2><a name="7.5"></a>7.5. Can I have write access to the git tree?</h2>

View File

@@ -17,7 +17,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 2.7.5" "February 2017"
.TH NANO 1 "version 2.8.0" "March 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME

View File

@@ -6,8 +6,8 @@
@smallbook
@set EDITION 0.4
@set VERSION 2.7.5
@set UPDATED February 2017
@set VERSION 2.8.0
@set UPDATED March 2017
@dircategory Editors
@direntry
@@ -21,7 +21,7 @@
@titlepage
@title GNU @code{nano}
@subtitle a small and friendly text editor.
@subtitle version 2.7.5
@subtitle version 2.8.0
@author Chris Allegretta
@page
@@ -743,6 +743,10 @@ Don't convert files from DOS/Mac format.
@item set nohelp
Don't display the help lists at the bottom of the screen.
@item set nopauses
Don't pause between warnings at startup. This means that only
the last one will be visible (when there are multiple ones).
@item set nonewlines
Don't add newlines to the ends of files.
@@ -1391,7 +1395,7 @@ browser exits.
@chapter Pico Compatibility
@code{nano} attempts to emulate Pico as closely as possible, but there
are certain differences between the editors:
are some differences between the editors:
@table @code
@@ -1405,12 +1409,29 @@ ask any more), or Cancel (stop with replacing).
@item Search and Replace History
When the option @code{-H} or @code{--historylog} is given (or set in
the .nanorc file), text entered as search or replace strings is stored.
These strings can be accessed with the up/down arrow keys. A retrieved
string can subsequently be edited.
These strings can be accessed with the up/down arrow keys, or you can
type the first few characters and then use Tab to cycle through the
matching strings. A retrieved string can subsequently be edited.
@item Writing, Appending, or Prepending Selected Text to Files
Text selected using the marking key (^^) can be written out, appended,
or prepended to a new or existing file using the WriteOut key (^O).
@item Position History
When the option @code{-P} or @code{--positionlog} is given (or set in
the .nanorc file), @code{nano} will store the position of the cursor
when you close a file, and will place the cursor in that position
again when you later reopen the file.
@item Writing Selected Text to Files
When using the Write-Out key (^O), text that has been selected using the
marking key (^^) can not just be written out to a new (or existing) file,
it can also be appended or prepended to an existing file.
@item Reading Text from a Command
When using the Read-File key (^R), @code{nano} can not just read a file,
it can also read the output of a command to be run (^X).
@item File Browser
In the file browser, @code{nano} does not implement the Add, Copy,
Rename, and Delete commands that Pico provides. In @code{nano} the
browser is just a file browser, not a file manager.
@item Toggles
Many options which alter the functionality of the program can be

View File

@@ -17,7 +17,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 2.7.5" "February 2017"
.TH NANORC 5 "version 2.8.0" "March 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -151,6 +151,10 @@ Don't display the two help lines at the bottom of the screen.
.B set nonewlines
Don't automatically add a newline to the ends of files.
.TP
.B set nopauses
Don't pause between warnings at startup. This means that only
the last one will be visible (when there are multiple ones).
.TP
.B set nowrap
Don't hard-wrap text at all.
.TP

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 2.7.5" "February 2017"
.TH RNANO 1 "version 2.8.0" "March 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME

View File

@@ -95,6 +95,10 @@
## Don't display the helpful shortcut lists at the bottom of the screen.
# set nohelp
## Don't pause between warnings at startup. Which means that only the
## last one will be readable (when there are multiple ones).
# set nopauses
## Don't add newlines to the ends of files.
# set nonewlines
@@ -198,10 +202,16 @@
## Paint the interface elements of nano.
## These are examples; by default there are no colors.
# set titlecolor brightwhite,blue
# set numbercolor cyan
# set statuscolor brightwhite,green
# set keycolor green
# set functioncolor yellow
# set numbercolor cyan
# set keycolor cyan
# set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor brightwhite,red
# set statuscolor brightwhite,red
# set numbercolor magenta
# set keycolor brightmagenta
# set functioncolor magenta
## Setup of syntax coloring.

View File

@@ -1,5 +1,36 @@
EXTRA_DIST = ac_define_dir.m4 codeset.m4 gettext.m4 glib-2.0.m4 \
glibc21.m4 iconv.m4 intdiv0.m4 inttypes_h.m4 \
inttypes.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 \
lib-ld.m4 lib-link.m4 lib-prefix.m4 progtest.m4 \
stdint_h.m4 uintmax_t.m4 ulonglong.m4
EXTRA_DIST = \
ac_define_dir.m4 \
ax_check_compile_flag.m4 \
codeset.m4 \
extern-inline.m4 \
fcntl-o.m4 \
gettext.m4 \
glibc21.m4 \
glibc2.m4 \
gnulib-cache.m4 \
iconv.m4 \
intdiv0.m4 \
intldir.m4 \
intl.m4 \
intlmacosx.m4 \
intmax.m4 \
inttypes_h.m4 \
inttypes-pri.m4 \
lcmessage.m4 \
lib-ld.m4 \
lib-link.m4 \
lib-prefix.m4 \
lock.m4 \
longlong.m4 \
nls.m4 \
po.m4 \
printf-posix.m4 \
progtest.m4 \
size_max.m4 \
stdint_h.m4 \
threadlib.m4 \
uintmax_t.m4 \
visibility.m4 \
wchar_t.m4 \
wint_t.m4 \
xsize.m4

View File

@@ -1,23 +0,0 @@
# codeset.m4 serial AM1 (gettext-0.10.40)
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
AC_DEFUN([AM_LANGINFO_CODESET],
[
AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
[AC_TRY_LINK([#include <langinfo.h>],
[char* cs = nl_langinfo(CODESET);],
am_cv_langinfo_codeset=yes,
am_cv_langinfo_codeset=no)
])
if test $am_cv_langinfo_codeset = yes; then
AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
fi
])

View File

@@ -1,587 +0,0 @@
# gettext.m4 serial 17 (gettext-0.11.5)
dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl
dnl This file can can be used in projects which are not available under
dnl the GNU General Public License or the GNU Library General Public
dnl License but which still want to provide support for the GNU gettext
dnl functionality.
dnl Please note that the actual code of the GNU gettext library is covered
dnl by the GNU Library General Public License, and the rest of the GNU
dnl gettext package package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
dnl Authors:
dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
dnl Bruno Haible <haible@clisp.cons.org>, 2000-2002.
dnl Macro to add for using GNU gettext.
dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
dnl default (if it is not specified or empty) is 'no-libtool'.
dnl INTLSYMBOL should be 'external' for packages with no intl directory,
dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory.
dnl If INTLSYMBOL is 'use-libtool', then a libtool library
dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
dnl depending on --{enable,disable}-{shared,static} and on the presence of
dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
dnl $(top_builddir)/intl/libintl.a will be created.
dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
dnl implementations (in libc or libintl) without the ngettext() function
dnl will be ignored. If NEEDSYMBOL is specified and is
dnl 'need-formatstring-macros', then GNU gettext implementations that don't
dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
dnl INTLDIR is used to find the intl libraries. If empty,
dnl the value `$(top_builddir)/intl/' is used.
dnl
dnl The result of the configuration is one of three cases:
dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
dnl and used.
dnl Catalog format: GNU --> install in $(datadir)
dnl Catalog extension: .mo after installation, .gmo in source tree
dnl 2) GNU gettext has been found in the system's C library.
dnl Catalog format: GNU --> install in $(datadir)
dnl Catalog extension: .mo after installation, .gmo in source tree
dnl 3) No internationalization, always use English msgid.
dnl Catalog format: none
dnl Catalog extension: none
dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
dnl The use of .gmo is historical (it was needed to avoid overwriting the
dnl GNU format catalogs when building on a platform with an X/Open gettext),
dnl but we keep it in order not to force irrelevant filename changes on the
dnl maintainers.
dnl
AC_DEFUN([AM_GNU_GETTEXT],
[
dnl Argument checking.
ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
[errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
])])])])])
ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
[errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
])])])])
define(gt_included_intl, ifelse([$1], [external], [no], [yes]))
define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], []))
AC_REQUIRE([AM_PO_SUBDIRS])dnl
ifelse(gt_included_intl, yes, [
AC_REQUIRE([AM_INTL_SUBDIR])dnl
])
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
dnl Sometimes libintl requires libiconv, so first search for libiconv.
dnl Ideally we would do this search only after the
dnl if test "$USE_NLS" = "yes"; then
dnl if test "$gt_cv_func_gnugettext_libc" != "yes"; then
dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
dnl the configure script would need to contain the same shell code
dnl again, outside any 'if'. There are two solutions:
dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
dnl documented, we avoid it.
ifelse(gt_included_intl, yes, , [
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
])
AC_MSG_CHECKING([whether NLS is requested])
dnl Default is enabled NLS
AC_ARG_ENABLE(nls,
[ --disable-nls do not use Native Language Support],
USE_NLS=$enableval, USE_NLS=yes)
AC_MSG_RESULT($USE_NLS)
AC_SUBST(USE_NLS)
ifelse(gt_included_intl, yes, [
BUILD_INCLUDED_LIBINTL=no
USE_INCLUDED_LIBINTL=no
])
LIBINTL=
LTLIBINTL=
POSUB=
dnl If we use NLS figure out what method
if test "$USE_NLS" = "yes"; then
gt_use_preinstalled_gnugettext=no
ifelse(gt_included_intl, yes, [
AC_MSG_CHECKING([whether included gettext is requested])
AC_ARG_WITH(included-gettext,
[ --with-included-gettext use the GNU gettext library included here],
nls_cv_force_use_gnu_gettext=$withval,
nls_cv_force_use_gnu_gettext=no)
AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
])
dnl User does not insist on using GNU NLS library. Figure out what
dnl to use. If GNU gettext is available we use this. Else we have
dnl to fall back to GNU NLS library.
dnl Add a version number to the cache macros.
define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1)))
define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
[AC_TRY_LINK([#include <libintl.h>
]ifelse([$2], [need-formatstring-macros],
[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
#endif
changequote(,)dnl
typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
changequote([,])dnl
], [])[extern int _nl_msg_cat_cntr;
extern int *_nl_domain_bindings;],
[bindtextdomain ("", "");
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
gt_cv_func_gnugettext_libc=yes,
gt_cv_func_gnugettext_libc=no)])
if test "$gt_cv_func_gnugettext_libc" != "yes"; then
dnl Sometimes libintl requires libiconv, so first search for libiconv.
ifelse(gt_included_intl, yes, , [
AM_ICONV_LINK
])
dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
dnl even if libiconv doesn't exist.
AC_LIB_LINKFLAGS_BODY([intl])
AC_CACHE_CHECK([for GNU gettext in libintl],
gt_cv_func_gnugettext_libintl,
[gt_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $INCINTL"
gt_save_LIBS="$LIBS"
LIBS="$LIBS $LIBINTL"
dnl Now see whether libintl exists and does not depend on libiconv.
AC_TRY_LINK([#include <libintl.h>
]ifelse([$2], [need-formatstring-macros],
[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
#endif
changequote(,)dnl
typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
changequote([,])dnl
], [])[extern int _nl_msg_cat_cntr;
extern
#ifdef __cplusplus
"C"
#endif
const char *_nl_expand_alias ();],
[bindtextdomain ("", "");
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
gt_cv_func_gnugettext_libintl=yes,
gt_cv_func_gnugettext_libintl=no)
dnl Now see whether libintl exists and depends on libiconv.
if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
LIBS="$LIBS $LIBICONV"
AC_TRY_LINK([#include <libintl.h>
]ifelse([$2], [need-formatstring-macros],
[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
#endif
changequote(,)dnl
typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
changequote([,])dnl
], [])[extern int _nl_msg_cat_cntr;
extern
#ifdef __cplusplus
"C"
#endif
const char *_nl_expand_alias ();],
[bindtextdomain ("", "");
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
[LIBINTL="$LIBINTL $LIBICONV"
LTLIBINTL="$LTLIBINTL $LTLIBICONV"
gt_cv_func_gnugettext_libintl=yes
])
fi
CPPFLAGS="$gt_save_CPPFLAGS"
LIBS="$gt_save_LIBS"])
fi
dnl If an already present or preinstalled GNU gettext() is found,
dnl use it. But if this macro is used in GNU gettext, and GNU
dnl gettext is already preinstalled in libintl, we update this
dnl libintl. (Cf. the install rule in intl/Makefile.in.)
if test "$gt_cv_func_gnugettext_libc" = "yes" \
|| { test "$gt_cv_func_gnugettext_libintl" = "yes" \
&& test "$PACKAGE" != gettext; }; then
gt_use_preinstalled_gnugettext=yes
else
dnl Reset the values set by searching for libintl.
LIBINTL=
LTLIBINTL=
INCINTL=
fi
ifelse(gt_included_intl, yes, [
if test "$gt_use_preinstalled_gnugettext" != "yes"; then
dnl GNU gettext is not found in the C library.
dnl Fall back on included GNU gettext library.
nls_cv_use_gnu_gettext=yes
fi
fi
if test "$nls_cv_use_gnu_gettext" = "yes"; then
dnl Mark actions used to generate GNU NLS library.
INTLOBJS="\$(GETTOBJS)"
BUILD_INCLUDED_LIBINTL=yes
USE_INCLUDED_LIBINTL=yes
LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV"
LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV"
LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
fi
if test "$gt_use_preinstalled_gnugettext" = "yes" \
|| test "$nls_cv_use_gnu_gettext" = "yes"; then
dnl Mark actions to use GNU gettext tools.
CATOBJEXT=.gmo
fi
])
if test "$gt_use_preinstalled_gnugettext" = "yes" \
|| test "$nls_cv_use_gnu_gettext" = "yes"; then
AC_DEFINE(ENABLE_NLS, 1,
[Define to 1 if translation of program messages to the user's native language
is requested.])
else
USE_NLS=no
fi
fi
if test "$USE_NLS" = "yes"; then
if test "$gt_use_preinstalled_gnugettext" = "yes"; then
if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
AC_MSG_CHECKING([how to link with libintl])
AC_MSG_RESULT([$LIBINTL])
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
fi
dnl For backward compatibility. Some packages may be using this.
AC_DEFINE(HAVE_GETTEXT, 1,
[Define if the GNU gettext() function is already present or preinstalled.])
AC_DEFINE(HAVE_DCGETTEXT, 1,
[Define if the GNU dcgettext() function is already present or preinstalled.])
fi
dnl We need to process the po/ directory.
POSUB=po
fi
ifelse(gt_included_intl, yes, [
dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
dnl to 'yes' because some of the testsuite requires it.
if test "$PACKAGE" = gettext; then
BUILD_INCLUDED_LIBINTL=yes
fi
dnl Make all variables we use known to autoconf.
AC_SUBST(BUILD_INCLUDED_LIBINTL)
AC_SUBST(USE_INCLUDED_LIBINTL)
AC_SUBST(CATOBJEXT)
AC_SUBST(INTLOBJS)
dnl For backward compatibility. Some configure.ins may be using this.
nls_cv_header_intl=
nls_cv_header_libgt=
dnl For backward compatibility. Some Makefiles may be using this.
DATADIRNAME=share
AC_SUBST(DATADIRNAME)
dnl For backward compatibility. Some Makefiles may be using this.
INSTOBJEXT=.mo
AC_SUBST(INSTOBJEXT)
dnl For backward compatibility. Some Makefiles may be using this.
GENCAT=gencat
AC_SUBST(GENCAT)
dnl Enable libtool support if the surrounding package wishes it.
INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
])
dnl For backward compatibility. Some Makefiles may be using this.
INTLLIBS="$LIBINTL"
AC_SUBST(INTLLIBS)
dnl Make all documented variables known to autoconf.
AC_SUBST(LIBINTL)
AC_SUBST(LTLIBINTL)
AC_SUBST(POSUB)
])
dnl Checks for all prerequisites of the po subdirectory,
dnl except for USE_NLS.
AC_DEFUN([AM_PO_SUBDIRS],
[
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
AC_REQUIRE([AM_MKINSTALLDIRS])dnl
dnl Perform the following tests also if --disable-nls has been given,
dnl because they are needed for "make dist" to work.
dnl Search for GNU msgfmt in the PATH.
dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
dnl The second test excludes FreeBSD msgfmt.
AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
[$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
(if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
:)
AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
dnl Search for GNU xgettext 0.11 or newer in the PATH.
dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
dnl The second test excludes FreeBSD xgettext.
AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
[$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
(if $ac_dir/$ac_word --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
:)
dnl Remove leftover from FreeBSD xgettext call.
rm -f messages.po
dnl Search for GNU msgmerge 0.11 or newer in the PATH.
AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
[$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :)
dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
dnl Test whether we really found GNU msgfmt.
if test "$GMSGFMT" != ":"; then
dnl If it is no GNU msgfmt we define it as : so that the
dnl Makefiles still can work.
if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 &&
(if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
: ;
else
GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'`
AC_MSG_RESULT(
[found $GMSGFMT program is not GNU msgfmt; ignore it])
GMSGFMT=":"
fi
fi
dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
dnl Test whether we really found GNU xgettext.
if test "$XGETTEXT" != ":"; then
dnl If it is no GNU xgettext we define it as : so that the
dnl Makefiles still can work.
if $XGETTEXT --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
(if $XGETTEXT --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
: ;
else
AC_MSG_RESULT(
[found xgettext program is not GNU xgettext; ignore it])
XGETTEXT=":"
fi
dnl Remove leftover from FreeBSD xgettext call.
rm -f messages.po
fi
AC_OUTPUT_COMMANDS([
for ac_file in $CONFIG_FILES; do
# Support "outfile[:infile[:infile...]]"
case "$ac_file" in
*:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
esac
# PO directories have a Makefile.in generated from Makefile.in.in.
case "$ac_file" in */Makefile.in)
# Adjust a relative srcdir.
ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
# In autoconf-2.13 it is called $ac_given_srcdir.
# In autoconf-2.50 it is called $srcdir.
test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
case "$ac_given_srcdir" in
.) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
/*) top_srcdir="$ac_given_srcdir" ;;
*) top_srcdir="$ac_dots$ac_given_srcdir" ;;
esac
if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
rm -f "$ac_dir/POTFILES"
test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
# ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend
# on $ac_dir but don't depend on user-specified configuration
# parameters.
if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
# The LINGUAS file contains the set of available languages.
if test -n "$ALL_LINGUAS"; then
test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
fi
ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"`
# Hide the ALL_LINGUAS assigment from automake.
eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
fi
case "$ac_given_srcdir" in
.) srcdirpre= ;;
*) srcdirpre='$(srcdir)/' ;;
esac
POFILES=
GMOFILES=
UPDATEPOFILES=
DUMMYPOFILES=
for lang in $ALL_LINGUAS; do
POFILES="$POFILES $srcdirpre$lang.po"
GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
done
# CATALOGS depends on both $ac_dir and the user's LINGUAS
# environment variable.
INST_LINGUAS=
if test -n "$ALL_LINGUAS"; then
for presentlang in $ALL_LINGUAS; do
useit=no
if test "%UNSET%" != "$LINGUAS"; then
desiredlanguages="$LINGUAS"
else
desiredlanguages="$ALL_LINGUAS"
fi
for desiredlang in $desiredlanguages; do
# Use the presentlang catalog if desiredlang is
# a. equal to presentlang, or
# b. a variant of presentlang (because in this case,
# presentlang can be used as a fallback for messages
# which are not translated in the desiredlang catalog).
case "$desiredlang" in
"$presentlang"*) useit=yes;;
esac
done
if test $useit = yes; then
INST_LINGUAS="$INST_LINGUAS $presentlang"
fi
done
fi
CATALOGS=
if test -n "$INST_LINGUAS"; then
for lang in $INST_LINGUAS; do
CATALOGS="$CATALOGS $lang.gmo"
done
fi
test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
if test -f "$f"; then
case "$f" in
*.orig | *.bak | *~) ;;
*) cat "$f" >> "$ac_dir/Makefile" ;;
esac
fi
done
fi
;;
esac
done],
[# Capture the value of obsolete ALL_LINGUAS because we need it to compute
# POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it
# from automake.
eval 'ALL_LINGUAS''="$ALL_LINGUAS"'
# Capture the value of LINGUAS because we need it to compute CATALOGS.
LINGUAS="${LINGUAS-%UNSET%}"
])
])
dnl Checks for all prerequisites of the intl subdirectory,
dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
AC_DEFUN([AM_INTL_SUBDIR],
[
AC_REQUIRE([AC_PROG_INSTALL])dnl
AC_REQUIRE([AM_MKINSTALLDIRS])dnl
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_PROG_RANLIB])dnl
AC_REQUIRE([AC_ISC_POSIX])dnl
AC_REQUIRE([AC_HEADER_STDC])dnl
AC_REQUIRE([AC_C_CONST])dnl
AC_REQUIRE([AC_C_INLINE])dnl
AC_REQUIRE([AC_TYPE_OFF_T])dnl
AC_REQUIRE([AC_TYPE_SIZE_T])dnl
AC_REQUIRE([AC_FUNC_ALLOCA])dnl
AC_REQUIRE([AC_FUNC_MMAP])dnl
AC_REQUIRE([jm_GLIBC21])dnl
AC_REQUIRE([gt_INTDIV0])dnl
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl
AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl
AC_REQUIRE([gt_INTTYPES_PRI])dnl
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
stdlib.h string.h unistd.h sys/param.h])
AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \
geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \
strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
AM_ICONV
AM_LANGINFO_CODESET
if test $ac_cv_header_locale_h = yes; then
AM_LC_MESSAGES
fi
dnl intl/plural.c is generated from intl/plural.y. It requires bison,
dnl because plural.y uses bison specific features. It requires at least
dnl bison-1.26 because earlier versions generate a plural.c that doesn't
dnl compile.
dnl bison is only needed for the maintainer (who touches plural.y). But in
dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
dnl the rule in general Makefile. Now, some people carelessly touch the
dnl files or have a broken "make" program, hence the plural.c rule will
dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
dnl present or too old.
AC_CHECK_PROGS([INTLBISON], [bison])
if test -z "$INTLBISON"; then
ac_verc_fail=yes
else
dnl Found it, now check the version.
AC_MSG_CHECKING([version of bison])
changequote(<<,>>)dnl
ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
case $ac_prog_version in
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
changequote([,])dnl
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
esac
AC_MSG_RESULT([$ac_prog_version])
fi
if test $ac_verc_fail = yes; then
INTLBISON=:
fi
])
AC_DEFUN([AM_MKINSTALLDIRS],
[
dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
dnl Try to locate is.
MKINSTALLDIRS=
if test -n "$ac_aux_dir"; then
MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
fi
if test -z "$MKINSTALLDIRS"; then
MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
fi
AC_SUBST(MKINSTALLDIRS)
])
dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])

View File

@@ -1,215 +0,0 @@
# Configure paths for GLIB
# Owen Taylor 1997-2001
dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject or
dnl gthread is specified in MODULES, pass to pkg-config
dnl
AC_DEFUN([AM_PATH_GLIB_2_0],
[dnl
dnl Get the cflags and libraries from pkg-config
dnl
AC_ARG_ENABLE(glibtest, [ --disable-glibtest do not try to compile and run a test GLIB program],
, enable_glibtest=yes)
pkg_config_args=glib-2.0
for module in . $4
do
case "$module" in
gmodule)
pkg_config_args="$pkg_config_args gmodule-2.0"
;;
gmodule-no-export)
pkg_config_args="$pkg_config_args gmodule-no-export-2.0"
;;
gobject)
pkg_config_args="$pkg_config_args gobject-2.0"
;;
gthread)
pkg_config_args="$pkg_config_args gthread-2.0"
;;
esac
done
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
no_glib=""
if test x$PKG_CONFIG != xno ; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then
:
else
echo *** pkg-config too old; version 0.7 or better required.
no_glib=yes
PKG_CONFIG=no
fi
else
no_glib=yes
fi
min_glib_version=ifelse([$1], ,2.0.0,$1)
AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
if test x$PKG_CONFIG != xno ; then
## don't try to run the test against uninstalled libtool libs
if $PKG_CONFIG --uninstalled $pkg_config_args; then
echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH"
enable_glibtest=no
fi
if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then
:
else
no_glib=yes
fi
fi
if test x"$no_glib" = x ; then
GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0`
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args`
GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args`
glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_glibtest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GLIB_CFLAGS"
LIBS="$GLIB_LIBS $LIBS"
dnl
dnl Now check if the installed GLIB is sufficiently new. (Also sanity
dnl checks the results of pkg-config to some extent)
dnl
rm -f conf.glibtest
AC_TRY_RUN([
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
int major, minor, micro;
char *tmp_version;
system ("touch conf.glibtest");
/* HP/UX 9 (%@#!) writes to sscanf strings */
tmp_version = g_strdup("$min_glib_version");
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
printf("%s, bad version string\n", "$min_glib_version");
exit(1);
}
if ((glib_major_version != $glib_config_major_version) ||
(glib_minor_version != $glib_config_minor_version) ||
(glib_micro_version != $glib_config_micro_version))
{
printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
$glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
glib_major_version, glib_minor_version, glib_micro_version);
printf ("*** was found! If pkg-config was correct, then it is best\n");
printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
printf("*** required on your system.\n");
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
printf("*** to point to the correct configuration files\n");
}
else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
(glib_minor_version != GLIB_MINOR_VERSION) ||
(glib_micro_version != GLIB_MICRO_VERSION))
{
printf("*** GLIB header files (version %d.%d.%d) do not match\n",
GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
printf("*** library (version %d.%d.%d)\n",
glib_major_version, glib_minor_version, glib_micro_version);
}
else
{
if ((glib_major_version > major) ||
((glib_major_version == major) && (glib_minor_version > minor)) ||
((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
{
return 0;
}
else
{
printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
glib_major_version, glib_minor_version, glib_micro_version);
printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
major, minor, micro);
printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
printf("***\n");
printf("*** If you have already installed a sufficiently new version, this error\n");
printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
printf("*** being found. The easiest way to fix this is to remove the old version\n");
printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
printf("*** correct copy of pkg-config. (In this case, you will have to\n");
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
printf("*** so that the correct libraries are found at run-time))\n");
}
}
return 1;
}
],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
if test "x$no_glib" = x ; then
AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version))
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$PKG_CONFIG" = "no" ; then
echo "*** A new enough version of pkg-config was not found."
echo "*** See http://www.freedesktop.org/software/pkgconfig/"
else
if test -f conf.glibtest ; then
:
else
echo "*** Could not run GLIB test program, checking why..."
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GLIB_CFLAGS"
LIBS="$LIBS $GLIB_LIBS"
AC_TRY_LINK([
#include <glib.h>
#include <stdio.h>
], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding GLIB or finding the wrong"
echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means GLIB is incorrectly installed."])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
GLIB_CFLAGS=""
GLIB_LIBS=""
GLIB_GENMARSHAL=""
GOBJECT_QUERY=""
GLIB_MKENUMS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
AC_SUBST(GLIB_GENMARSHAL)
AC_SUBST(GOBJECT_QUERY)
AC_SUBST(GLIB_MKENUMS)
rm -f conf.glibtest
])

View File

@@ -1,32 +0,0 @@
# glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40)
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
# Test for the GNU C Library, version 2.1 or newer.
# From Bruno Haible.
AC_DEFUN([jm_GLIBC21],
[
AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
ac_cv_gnu_library_2_1,
[AC_EGREP_CPP([Lucky GNU user],
[
#include <features.h>
#ifdef __GNU_LIBRARY__
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
Lucky GNU user
#endif
#endif
],
ac_cv_gnu_library_2_1=yes,
ac_cv_gnu_library_2_1=no)
]
)
AC_SUBST(GLIBC21)
GLIBC21="$ac_cv_gnu_library_2_1"
]
)

View File

@@ -1,103 +0,0 @@
# iconv.m4 serial AM4 (gettext-0.11.3)
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
[
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([iconv])
])
AC_DEFUN([AM_ICONV_LINK],
[
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
dnl those with the standalone portable GNU libiconv installed).
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
dnl Add $INCICONV to CPPFLAGS before performing the following checks,
dnl because if the user has installed libiconv and not disabled its use
dnl via --without-libiconv-prefix, he wants to use it. The first
dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
am_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_func_iconv=yes)
if test "$am_cv_func_iconv" != yes; then
am_save_LIBS="$LIBS"
LIBS="$LIBS $LIBICONV"
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_lib_iconv=yes
am_cv_func_iconv=yes)
LIBS="$am_save_LIBS"
fi
])
if test "$am_cv_func_iconv" = yes; then
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
fi
if test "$am_cv_lib_iconv" = yes; then
AC_MSG_CHECKING([how to link with libiconv])
AC_MSG_RESULT([$LIBICONV])
else
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
dnl either.
CPPFLAGS="$am_save_CPPFLAGS"
LIBICONV=
LTLIBICONV=
fi
AC_SUBST(LIBICONV)
AC_SUBST(LTLIBICONV)
])
AC_DEFUN([AM_ICONV],
[
AM_ICONV_LINK
if test "$am_cv_func_iconv" = yes; then
AC_MSG_CHECKING([for iconv declaration])
AC_CACHE_VAL(am_cv_proto_iconv, [
AC_TRY_COMPILE([
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
AC_MSG_RESULT([$]{ac_t:-
}[$]am_cv_proto_iconv)
AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
[Define as const if the declaration of iconv() needs const.])
fi
])

View File

@@ -1,72 +0,0 @@
# intdiv0.m4 serial 1 (gettext-0.11.3)
dnl Copyright (C) 2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
AC_DEFUN([gt_INTDIV0],
[
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
gt_cv_int_divbyzero_sigfpe,
[
AC_TRY_RUN([
#include <stdlib.h>
#include <signal.h>
static void
#ifdef __cplusplus
sigfpe_handler (int sig)
#else
sigfpe_handler (sig) int sig;
#endif
{
/* Exit with code 0 if SIGFPE, with code 1 if any other signal. */
exit (sig != SIGFPE);
}
int x = 1;
int y = 0;
int z;
int nan;
int main ()
{
signal (SIGFPE, sigfpe_handler);
/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */
#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
signal (SIGTRAP, sigfpe_handler);
#endif
/* Linux/SPARC yields signal SIGILL. */
#if defined (__sparc__) && defined (__linux__)
signal (SIGILL, sigfpe_handler);
#endif
z = x / y;
nan = y / y;
exit (1);
}
], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no,
[
# Guess based on the CPU.
case "$host_cpu" in
alpha* | i[34567]86 | m68k | s390*)
gt_cv_int_divbyzero_sigfpe="guessing yes";;
*)
gt_cv_int_divbyzero_sigfpe="guessing no";;
esac
])
])
case "$gt_cv_int_divbyzero_sigfpe" in
*yes) value=1;;
*) value=0;;
esac
AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value,
[Define if integer division by zero raises signal SIGFPE.])
])

View File

@@ -1,32 +0,0 @@
# inttypes-pri.m4 serial 1 (gettext-0.11.4)
dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
# Define PRI_MACROS_BROKEN if <inttypes.h> exists and defines the PRI*
# macros to non-string values. This is the case on AIX 4.3.3.
AC_DEFUN([gt_INTTYPES_PRI],
[
AC_REQUIRE([gt_HEADER_INTTYPES_H])
if test $gt_cv_header_inttypes_h = yes; then
AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken],
gt_cv_inttypes_pri_broken,
[
AC_TRY_COMPILE([#include <inttypes.h>
#ifdef PRId32
char *p = PRId32;
#endif
], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes)
])
fi
if test "$gt_cv_inttypes_pri_broken" = yes; then
AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1,
[Define if <inttypes.h> exists and defines unusable PRI* macros.])
fi
])

View File

@@ -1,27 +0,0 @@
# inttypes.m4 serial 1 (gettext-0.11.4)
dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert.
# Define HAVE_INTTYPES_H if <inttypes.h> exists and doesn't clash with
# <sys/types.h>.
AC_DEFUN([gt_HEADER_INTTYPES_H],
[
AC_CACHE_CHECK([for inttypes.h], gt_cv_header_inttypes_h,
[
AC_TRY_COMPILE(
[#include <sys/types.h>
#include <inttypes.h>],
[], gt_cv_header_inttypes_h=yes, gt_cv_header_inttypes_h=no)
])
if test $gt_cv_header_inttypes_h = yes; then
AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
[Define if <inttypes.h> exists and doesn't clash with <sys/types.h>.])
fi
])

View File

@@ -1,28 +0,0 @@
# inttypes_h.m4 serial 4 (gettext-0.11.4)
dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert.
# Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
# doesn't clash with <sys/types.h>, and declares uintmax_t.
AC_DEFUN([jm_AC_HEADER_INTTYPES_H],
[
AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <inttypes.h>],
[uintmax_t i = (uintmax_t) -1;],
jm_ac_cv_header_inttypes_h=yes,
jm_ac_cv_header_inttypes_h=no)])
if test $jm_ac_cv_header_inttypes_h = yes; then
AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1,
[Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
and declares uintmax_t. ])
fi
])

View File

@@ -1,26 +0,0 @@
# isc-posix.m4 serial 2 (gettext-0.11.2)
dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
# This file is not needed with autoconf-2.53 and newer. Remove it in 2005.
# This test replaces the one in autoconf.
# Currently this macro should have the same name as the autoconf macro
# because gettext's gettext.m4 (distributed in the automake package)
# still uses it. Otherwise, the use in gettext.m4 makes autoheader
# give these diagnostics:
# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
undefine([AC_ISC_POSIX])
AC_DEFUN([AC_ISC_POSIX],
[
dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
]
)

View File

@@ -1,32 +0,0 @@
# lcmessage.m4 serial 3 (gettext-0.11.3)
dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl
dnl This file can can be used in projects which are not available under
dnl the GNU General Public License or the GNU Library General Public
dnl License but which still want to provide support for the GNU gettext
dnl functionality.
dnl Please note that the actual code of the GNU gettext library is covered
dnl by the GNU Library General Public License, and the rest of the GNU
dnl gettext package package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
dnl Authors:
dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
# Check whether LC_MESSAGES is available in <locale.h>.
AC_DEFUN([AM_LC_MESSAGES],
[
AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
[AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
if test $am_cv_val_LC_MESSAGES = yes; then
AC_DEFINE(HAVE_LC_MESSAGES, 1,
[Define if your <locale.h> file defines LC_MESSAGES.])
fi
])

View File

@@ -1,97 +0,0 @@
# lib-ld.m4 serial 1 (gettext-0.11)
dnl Copyright (C) 1996-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl Subroutines of libtool.m4,
dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
dnl with libtool.m4.
dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
AC_DEFUN([AC_LIB_PROG_LD_GNU],
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
acl_cv_prog_gnu_ld=yes
else
acl_cv_prog_gnu_ld=no
fi])
with_gnu_ld=$acl_cv_prog_gnu_ld
])
dnl From libtool-1.4. Sets the variable LD.
AC_DEFUN([AC_LIB_PROG_LD],
[AC_ARG_WITH(gnu-ld,
[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
ac_prog=ld
if test "$GCC" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by GCC])
case $host in
*-*-mingw*)
# gcc leaves a trailing carriage return which upsets mingw
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
*)
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
esac
case $ac_prog in
# Accept absolute paths.
[[\\/]* | [A-Za-z]:[\\/]*)]
[re_direlt='/[^/][^/]*/\.\./']
# Canonicalize the path of ld
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL(acl_cv_path_LD,
[if test -z "$LD"; then
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
for ac_dir in $PATH; do
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
acl_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some GNU ld's only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
test "$with_gnu_ld" != no && break
else
test "$with_gnu_ld" != yes && break
fi
fi
done
IFS="$ac_save_ifs"
else
acl_cv_path_LD="$LD" # Let the user override the test with a path.
fi])
LD="$acl_cv_path_LD"
if test -n "$LD"; then
AC_MSG_RESULT($LD)
else
AC_MSG_RESULT(no)
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
AC_LIB_PROG_LD_GNU
])

View File

@@ -1,554 +0,0 @@
# lib-link.m4 serial 3 (gettext-0.11.3)
dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
dnl augments the CPPFLAGS variable.
AC_DEFUN([AC_LIB_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
define([Name],[translit([$1],[./-], [___])])
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
AC_LIB_LINKFLAGS_BODY([$1], [$2])
ac_cv_lib[]Name[]_libs="$LIB[]NAME"
ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
])
LIB[]NAME="$ac_cv_lib[]Name[]_libs"
LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
dnl results of this search when this library appears as a dependency.
HAVE_LIB[]NAME=yes
undefine([Name])
undefine([NAME])
])
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
dnl searches for libname and the libraries corresponding to explicit and
dnl implicit dependencies, together with the specified include files and
dnl the ability to compile and link the specified testcode. If found, it
dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
define([Name],[translit([$1],[./-], [___])])
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([$1], [$2])
dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
dnl because if the user has installed lib[]Name and not disabled its use
dnl via --without-lib[]Name-prefix, he wants to use it.
ac_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
ac_save_LIBS="$LIBS"
LIBS="$LIBS $LIB[]NAME"
AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
LIBS="$ac_save_LIBS"
])
if test "$ac_cv_lib[]Name" = yes; then
HAVE_LIB[]NAME=yes
AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
AC_MSG_CHECKING([how to link with lib[]$1])
AC_MSG_RESULT([$LIB[]NAME])
else
HAVE_LIB[]NAME=no
dnl If $LIB[]NAME didn't lead to a usable library, we don't need
dnl $INC[]NAME either.
CPPFLAGS="$ac_save_CPPFLAGS"
LIB[]NAME=
LTLIB[]NAME=
fi
AC_SUBST([HAVE_LIB]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
undefine([Name])
undefine([NAME])
])
dnl Determine the platform dependent parameters needed to use rpath:
dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
dnl hardcode_direct, hardcode_minus_L,
dnl sys_lib_search_path_spec, sys_lib_dlsearch_path_spec.
AC_DEFUN([AC_LIB_RPATH],
[
AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
. ./conftest.sh
rm -f ./conftest.sh
acl_cv_rpath=done
])
wl="$acl_cv_wl"
libext="$acl_cv_libext"
shlibext="$acl_cv_shlibext"
hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
hardcode_direct="$acl_cv_hardcode_direct"
hardcode_minus_L="$acl_cv_hardcode_minus_L"
sys_lib_search_path_spec="$acl_cv_sys_lib_search_path_spec"
sys_lib_dlsearch_path_spec="$acl_cv_sys_lib_dlsearch_path_spec"
dnl Determine whether the user wants rpath handling at all.
AC_ARG_ENABLE(rpath,
[ --disable-rpath do not hardcode runtime library paths],
:, enable_rpath=yes)
])
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
[
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_ARG_WITH([lib$1-prefix],
[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
--without-lib$1-prefix don't search for lib$1 in includedir and libdir],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/lib"
fi
fi
])
dnl Search the library and its dependencies in $additional_libdir and
dnl $LDFLAGS. Using breadth-first-seach.
LIB[]NAME=
LTLIB[]NAME=
INC[]NAME=
rpathdirs=
ltrpathdirs=
names_already_handled=
names_next_round='$1 $2'
while test -n "$names_next_round"; do
names_this_round="$names_next_round"
names_next_round=
for name in $names_this_round; do
already_handled=
for n in $names_already_handled; do
if test "$n" = "$name"; then
already_handled=yes
break
fi
done
if test -z "$already_handled"; then
names_already_handled="$names_already_handled $name"
dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
dnl or AC_LIB_HAVE_LINKFLAGS call.
uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
eval value=\"\$HAVE_LIB$uppername\"
if test -n "$value"; then
if test "$value" = yes; then
eval value=\"\$LIB$uppername\"
test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
eval value=\"\$LTLIB$uppername\"
test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
else
dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
dnl that this library doesn't exist. So just drop it.
:
fi
else
dnl Search the library lib$name in $additional_libdir and $LDFLAGS
dnl and the already constructed $LIBNAME/$LTLIBNAME.
found_dir=
found_la=
found_so=
found_a=
if test $use_additional = yes; then
if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
found_dir="$additional_libdir"
found_so="$additional_libdir/lib$name.$shlibext"
if test -f "$additional_libdir/lib$name.la"; then
found_la="$additional_libdir/lib$name.la"
fi
else
if test -f "$additional_libdir/lib$name.$libext"; then
found_dir="$additional_libdir"
found_a="$additional_libdir/lib$name.$libext"
if test -f "$additional_libdir/lib$name.la"; then
found_la="$additional_libdir/lib$name.la"
fi
fi
fi
fi
if test "X$found_dir" = "X"; then
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
case "$x" in
-L*)
dir=`echo "X$x" | sed -e 's/^X-L//'`
if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
found_dir="$dir"
found_so="$dir/lib$name.$shlibext"
if test -f "$dir/lib$name.la"; then
found_la="$dir/lib$name.la"
fi
else
if test -f "$dir/lib$name.$libext"; then
found_dir="$dir"
found_a="$dir/lib$name.$libext"
if test -f "$dir/lib$name.la"; then
found_la="$dir/lib$name.la"
fi
fi
fi
;;
esac
if test "X$found_dir" != "X"; then
break
fi
done
fi
if test "X$found_dir" != "X"; then
dnl Found the library.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
if test "X$found_so" != "X"; then
dnl Linking with a shared library. We attempt to hardcode its
dnl directory into the executable's runpath, unless it's the
dnl standard /usr/lib.
if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
dnl No hardcoding is needed.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $found_dir"
fi
dnl The hardcoding into $LIBNAME is system dependent.
if test "$hardcode_direct" = yes; then
dnl Using DIR/libNAME.so during linking hardcodes DIR into the
dnl resulting binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $found_dir"
fi
else
dnl Rely on "-L$found_dir".
dnl But don't add it if it's already contained in the LDFLAGS
dnl or the already constructed $LIBNAME
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
fi
if test "$hardcode_minus_L" != no; then
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
dnl here, because this doesn't fit in flags passed to the
dnl compiler. So give up. No hardcoding. This affects only
dnl very old systems.
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
fi
fi
fi
fi
else
if test "X$found_a" != "X"; then
dnl Linking with a static library.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
else
dnl We shouldn't come here, but anyway it's good to have a
dnl fallback.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
fi
fi
dnl Assume the include files are nearby.
additional_includedir=
case "$found_dir" in
*/lib | */lib/)
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
additional_includedir="$basedir/include"
;;
esac
if test "X$additional_includedir" != "X"; then
dnl Potentially add $additional_includedir to $INCNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's /usr/local/include and we are using GCC on Linux,
dnl 3. if it's already present in $CPPFLAGS or the already
dnl constructed $INCNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
for x in $CPPFLAGS $INC[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $INCNAME.
INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
fi
fi
fi
fi
fi
dnl Look for dependencies.
if test -n "$found_la"; then
dnl Read the .la file. It defines the variables
dnl dlname, library_names, old_library, dependency_libs, current,
dnl age, revision, installed, dlopen, dlpreopen, libdir.
save_libdir="$libdir"
case "$found_la" in
*/* | *\\*) . "$found_la" ;;
*) . "./$found_la" ;;
esac
libdir="$save_libdir"
dnl We use only dependency_libs.
for dep in $dependency_libs; do
case "$dep" in
-L*)
additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
dnl 3. if it's already present in $LDFLAGS or the already
dnl constructed $LIBNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/lib"; then
haveit=
if test "X$additional_libdir" = "X/usr/local/lib"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LIBNAME.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
fi
fi
haveit=
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LTLIBNAME.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
fi
fi
fi
fi
;;
-R*)
dir=`echo "X$dep" | sed -e 's/^X-R//'`
if test "$enable_rpath" != no; then
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $dir"
fi
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $dir"
fi
fi
;;
-l*)
dnl Handle this in the next round.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
;;
*.la)
dnl Handle this in the next round. Throw away the .la's
dnl directory; it is already contained in a preceding -L
dnl option.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
;;
*)
dnl Most likely an immediate library name.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
;;
esac
done
fi
else
dnl Didn't find the library; assume it is in the system directories
dnl known to the linker and runtime loader. (All the system
dnl directories known to the linker should also be known to the
dnl runtime loader, otherwise the system is severely misconfigured.)
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
fi
fi
fi
done
done
if test "X$rpathdirs" != "X"; then
if test -n "$hardcode_libdir_separator"; then
dnl Weird platform: only the last -rpath option counts, the user must
dnl pass all path elements in one option. We can arrange that for a
dnl single library, but not when more than one $LIBNAMEs are used.
alldirs=
for found_dir in $rpathdirs; do
alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
done
dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
acl_save_libdir="$libdir"
libdir="$alldirs"
eval flag=\"$hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
else
dnl The -rpath options are cumulative.
for found_dir in $rpathdirs; do
acl_save_libdir="$libdir"
libdir="$found_dir"
eval flag=\"$hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
done
fi
fi
if test "X$ltrpathdirs" != "X"; then
dnl When using libtool, the option that works for both libraries and
dnl executables is -R. The -R options are cumulative.
for found_dir in $ltrpathdirs; do
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
done
fi
])
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
dnl unless already present in VAR.
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
dnl contains two or three consecutive elements that belong together.
AC_DEFUN([AC_LIB_APPENDTOVAR],
[
for element in [$2]; do
haveit=
for x in $[$1]; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X$element"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
[$1]="${[$1]}${[$1]:+ }$element"
fi
done
])

View File

@@ -1,148 +0,0 @@
# lib-prefix.m4 serial 1 (gettext-0.11)
dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
dnl to access previously installed libraries. The basic assumption is that
dnl a user will want packages to use other packages he previously installed
dnl with the same --prefix option.
dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
dnl libraries, but is otherwise very convenient.
AC_DEFUN([AC_LIB_PREFIX],
[
AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_ARG_WITH([lib-prefix],
[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
--without-lib-prefix don't search for libraries in includedir and libdir],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/lib"
fi
fi
])
if test $use_additional = yes; then
dnl Potentially add $additional_includedir to $CPPFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's already present in $CPPFLAGS,
dnl 3. if it's /usr/local/include and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
for x in $CPPFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $CPPFLAGS.
CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
fi
fi
fi
fi
dnl Potentially add $additional_libdir to $LDFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's already present in $LDFLAGS,
dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/lib"; then
haveit=
for x in $LDFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_libdir" = "X/usr/local/lib"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LDFLAGS.
LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
fi
fi
fi
fi
fi
])
dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
dnl acl_final_exec_prefix, containing the values to which $prefix and
dnl $exec_prefix will expand at the end of the configure script.
AC_DEFUN([AC_LIB_PREPARE_PREFIX],
[
dnl Unfortunately, prefix and exec_prefix get only finally determined
dnl at the end of configure.
if test "X$prefix" = "XNONE"; then
acl_final_prefix="$ac_default_prefix"
else
acl_final_prefix="$prefix"
fi
if test "X$exec_prefix" = "XNONE"; then
acl_final_exec_prefix='${prefix}'
else
acl_final_exec_prefix="$exec_prefix"
fi
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
prefix="$acl_save_prefix"
])
dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
dnl variables prefix and exec_prefix bound to the values they will have
dnl at the end of the configure script.
AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
[
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
acl_save_exec_prefix="$exec_prefix"
exec_prefix="$acl_final_exec_prefix"
$1
exec_prefix="$acl_save_exec_prefix"
prefix="$acl_save_prefix"
])

View File

@@ -1,59 +0,0 @@
# progtest.m4 serial 2 (gettext-0.10.40)
dnl Copyright (C) 1996-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl
dnl This file can can be used in projects which are not available under
dnl the GNU General Public License or the GNU Library General Public
dnl License but which still want to provide support for the GNU gettext
dnl functionality.
dnl Please note that the actual code of the GNU gettext library is covered
dnl by the GNU Library General Public License, and the rest of the GNU
dnl gettext package package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
dnl Authors:
dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
# Search path for a program which passes the given test.
dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
AC_DEFUN([AM_PATH_PROG_WITH_TEST],
[# Extract the first word of "$2", so it can be a program name with args.
set dummy $2; ac_word=[$]2
AC_MSG_CHECKING([for $ac_word])
AC_CACHE_VAL(ac_cv_path_$1,
[case "[$]$1" in
/*)
ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
;;
*)
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
for ac_dir in ifelse([$5], , $PATH, [$5]); do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
if [$3]; then
ac_cv_path_$1="$ac_dir/$ac_word"
break
fi
fi
done
IFS="$ac_save_ifs"
dnl If no 4th arg is given, leave the cache variable unset,
dnl so AC_PATH_PROGS will keep looking.
ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
])dnl
;;
esac])dnl
$1="$ac_cv_path_$1"
if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
AC_MSG_RESULT([$]$1)
else
AC_MSG_RESULT(no)
fi
AC_SUBST($1)dnl
])

View File

@@ -1,28 +0,0 @@
# stdint_h.m4 serial 2 (gettext-0.11.4)
dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert.
# Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
# doesn't clash with <sys/types.h>, and declares uintmax_t.
AC_DEFUN([jm_AC_HEADER_STDINT_H],
[
AC_CACHE_CHECK([for stdint.h], jm_ac_cv_header_stdint_h,
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <stdint.h>],
[uintmax_t i = (uintmax_t) -1;],
jm_ac_cv_header_stdint_h=yes,
jm_ac_cv_header_stdint_h=no)])
if test $jm_ac_cv_header_stdint_h = yes; then
AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1,
[Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
and declares uintmax_t. ])
fi
])

View File

@@ -1,29 +0,0 @@
# uintmax_t.m4 serial 6 (gettext-0.11)
dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert.
AC_PREREQ(2.13)
# Define uintmax_t to `unsigned long' or `unsigned long long'
# if <inttypes.h> does not exist.
AC_DEFUN([jm_AC_TYPE_UINTMAX_T],
[
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
AC_REQUIRE([jm_AC_HEADER_STDINT_H])
if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then
AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
test $ac_cv_type_unsigned_long_long = yes \
&& ac_type='unsigned long long' \
|| ac_type='unsigned long'
AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
[Define to unsigned long or unsigned long long
if <inttypes.h> and <stdint.h> don't define.])
fi
])

View File

@@ -1,23 +0,0 @@
# ulonglong.m4 serial 2 (fileutils-4.0.32, gettext-0.10.40)
dnl Copyright (C) 1999-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert.
AC_DEFUN([jm_AC_TYPE_UNSIGNED_LONG_LONG],
[
AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
[AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
[unsigned long long ullmax = (unsigned long long) -1;
return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
ac_cv_type_unsigned_long_long=yes,
ac_cv_type_unsigned_long_long=no)])
if test $ac_cv_type_unsigned_long_long = yes; then
AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
[Define if you have the unsigned long long type.])
fi
])

3
po/.gitignore vendored
View File

@@ -1,6 +1,7 @@
/*.gmo
/Makefile.in.in
/Makevars.template
/Rules-quot
/boldquot.sed
/en@boldquot.header
@@ -8,4 +9,6 @@
/insert-header.sin
/POTFILES
/quot.sed
/remove-potcdate.sed
/remove-potcdate.sin
/stamp-po

1269
po/bg.po

File diff suppressed because it is too large Load Diff

1167
po/ca.po

File diff suppressed because it is too large Load Diff

1143
po/cs.po

File diff suppressed because it is too large Load Diff

1109
po/da.po

File diff suppressed because it is too large Load Diff

1154
po/de.po

File diff suppressed because it is too large Load Diff

1156
po/eo.po

File diff suppressed because it is too large Load Diff

1151
po/es.po

File diff suppressed because it is too large Load Diff

1269
po/eu.po

File diff suppressed because it is too large Load Diff

1105
po/fi.po

File diff suppressed because it is too large Load Diff

1502
po/fr.po

File diff suppressed because it is too large Load Diff

1150
po/ga.po

File diff suppressed because it is too large Load Diff

1143
po/gl.po

File diff suppressed because it is too large Load Diff

1138
po/hr.po

File diff suppressed because it is too large Load Diff

1193
po/hu.po

File diff suppressed because it is too large Load Diff

1267
po/id.po

File diff suppressed because it is too large Load Diff

1202
po/it.po

File diff suppressed because it is too large Load Diff

1121
po/ja.po

File diff suppressed because it is too large Load Diff

1267
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1152
po/nb.po

File diff suppressed because it is too large Load Diff

1152
po/nl.po

File diff suppressed because it is too large Load Diff

1257
po/nn.po

File diff suppressed because it is too large Load Diff

1143
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1157
po/ro.po

File diff suppressed because it is too large Load Diff

1271
po/ru.po

File diff suppressed because it is too large Load Diff

1267
po/sl.po

File diff suppressed because it is too large Load Diff

1143
po/sr.po

File diff suppressed because it is too large Load Diff

1143
po/sv.po

File diff suppressed because it is too large Load Diff

1419
po/tr.po

File diff suppressed because it is too large Load Diff

1157
po/uk.po

File diff suppressed because it is too large Load Diff

1150
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -DSYSCONFDIR=\"$(sysconfdir)\"
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -DSYSCONFDIR=\"$(sysconfdir)\" \
-I$(top_builddir)/lib -I$(top_srcdir)/lib
CLEANFILES = revision.h
@@ -37,7 +38,7 @@ nano_SOURCES = browser.c \
utils.c \
winio.c
nano_LDADD = @GLIB_LIBS@ @LIBINTL@
nano_LDADD = @LIBINTL@ $(top_builddir)/lib/libgnu.a
install-exec-hook:
cd $(DESTDIR)$(bindir) && rm -f rnano && $(LN_S) nano rnano

View File

@@ -297,7 +297,7 @@ char *do_browser(char *path)
/* If we are moving up one level, remember where we came from, so
* this directory can be highlighted and easily reentered. */
if (strcmp(tail(filelist[selected]), "..") == 0)
present_name = striponedir(filelist[selected]);
present_name = strip_last_component(filelist[selected]);
/* Try opening and reading the selected directory. */
path = mallocstrcpy(path, filelist[selected]);
@@ -353,7 +353,7 @@ char *do_browse_from(const char *inpath)
* at all. If so, we'll just pass the current directory to
* do_browser(). */
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
path = free_and_assign(path, striponedir(path));
path = free_and_assign(path, strip_last_component(path));
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
char * currentdir = charalloc(PATH_MAX + 1);
@@ -467,6 +467,10 @@ functionptrtype parse_browser_input(int *kbinput)
return do_help_void;
case 'E':
case 'e':
case 'Q':
case 'q':
case 'X':
case 'x':
return do_exit;
case 'G':
case 'g':
@@ -587,7 +591,7 @@ void browser_refresh(void)
/* Make sure info takes up no more than infomaxlen columns. */
infolen = strlenpt(info);
if (infolen > infomaxlen) {
null_at(&info, actual_x(info, infomaxlen));
info[actual_x(info, infomaxlen)] = '\0';
infolen = infomaxlen;
}
@@ -781,21 +785,17 @@ void do_last_file(void)
selected = filelist_len - 1;
}
/* Strip one directory from the end of path, and return the stripped
* path. The returned string is dynamically allocated, and should be
* freed. */
char *striponedir(const char *path)
/* Strip one element from the end of path, and return the stripped path.
* The returned string is dynamically allocated, and should be freed. */
char *strip_last_component(const char *path)
{
char *retval, *tmp;
char *copy = mallocstrcpy(NULL, path);
char *last_slash = strrchr(copy, '/');
retval = mallocstrcpy(NULL, path);
if (last_slash != NULL)
*last_slash = '\0';
tmp = strrchr(retval, '/');
if (tmp != NULL)
null_at(&retval, tmp - retval);
return retval;
return copy;
}
#endif /* !DISABLE_BROWSER */

View File

@@ -26,12 +26,8 @@
#include <ctype.h>
#ifdef ENABLE_UTF8
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
#ifdef HAVE_WCTYPE_H
#include <wctype.h>
#endif
static bool use_utf8 = FALSE;
/* Whether we've enabled UTF-8 support. */
@@ -61,22 +57,6 @@ char *addstrings(char* str1, size_t len1, char* str2, size_t len2)
return str1;
}
#ifndef HAVE_ISBLANK
/* This function is equivalent to isblank(). */
bool nisblank(int c)
{
return isspace(c) && (c == '\t' || !is_cntrl_char(c));
}
#endif
#if !defined(HAVE_ISWBLANK) && defined(ENABLE_UTF8)
/* This function is equivalent to iswblank(). */
bool niswblank(wchar_t wc)
{
return iswspace(wc) && (wc == '\t' || !is_cntrl_wchar(wc));
}
#endif
/* Return TRUE if the value of c is in byte range, and FALSE otherwise. */
bool is_byte(int c)
{
@@ -450,36 +430,12 @@ size_t move_mbright(const char *buf, size_t pos)
return pos + parse_mbchar(buf + pos, NULL, NULL);
}
#ifndef HAVE_STRCASECMP
/* This function is equivalent to strcasecmp(). */
int nstrcasecmp(const char *s1, const char *s2)
{
return strncasecmp(s1, s2, HIGHEST_POSITIVE);
}
#endif
/* This function is equivalent to strcasecmp() for multibyte strings. */
int mbstrcasecmp(const char *s1, const char *s2)
{
return mbstrncasecmp(s1, s2, HIGHEST_POSITIVE);
}
#ifndef HAVE_STRNCASECMP
/* This function is equivalent to strncasecmp(). */
int nstrncasecmp(const char *s1, const char *s2, size_t n)
{
if (s1 == s2)
return 0;
for (; *s1 != '\0' && *s2 != '\0' && n > 0; s1++, s2++, n--) {
if (tolower(*s1) != tolower(*s2))
break;
}
return (n > 0) ? tolower(*s1) - tolower(*s2) : 0;
}
#endif
/* This function is equivalent to strncasecmp() for multibyte strings. */
int mbstrncasecmp(const char *s1, const char *s2, size_t n)
{
@@ -524,28 +480,6 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
return strncasecmp(s1, s2, n);
}
#ifndef HAVE_STRCASESTR
/* This function is equivalent to strcasestr(). */
char *nstrcasestr(const char *haystack, const char *needle)
{
size_t needle_len;
if (*needle == '\0')
return (char *)haystack;
needle_len = strlen(needle);
while (*haystack != '\0') {
if (strncasecmp(haystack, needle, needle_len) == 0)
return (char *)haystack;
haystack++;
}
return NULL;
}
#endif
/* This function is equivalent to strcasestr() for multibyte strings. */
char *mbstrcasestr(const char *haystack, const char *needle)
{
@@ -665,19 +599,6 @@ size_t mbstrlen(const char *s)
return mbstrnlen(s, (size_t)-1);
}
#ifndef HAVE_STRNLEN
/* This function is equivalent to strnlen(). */
size_t nstrnlen(const char *s, size_t maxlen)
{
size_t n = 0;
for (; *s != '\0' && maxlen > 0; s++, maxlen--, n++)
;
return n;
}
#endif
/* This function is equivalent to strnlen() for multibyte strings. */
size_t mbstrnlen(const char *s, size_t maxlen)
{
@@ -815,7 +736,7 @@ char *mbrevstrpbrk(const char *s, const char *accept, const char
bool has_blank_chars(const char *s)
{
for (; *s != '\0'; s++) {
if (isblank(*s))
if (isblank((unsigned char)*s))
return TRUE;
}

View File

@@ -225,6 +225,7 @@ void do_copy_text(void)
/* Remember the current viewport and cursor position. */
ssize_t is_edittop_lineno = openfile->edittop->lineno;
size_t is_firstcolumn = openfile->firstcolumn;
ssize_t is_current_lineno = openfile->current->lineno;
size_t is_current_x = openfile->current_x;
@@ -239,6 +240,7 @@ void do_copy_text(void)
if (mark_set) {
/* Restore the viewport and cursor position. */
openfile->edittop = fsfromline(is_edittop_lineno);
openfile->firstcolumn = is_firstcolumn;
openfile->current = fsfromline(is_current_lineno);
openfile->current_x = is_current_x;
}
@@ -257,6 +259,9 @@ void do_cut_till_eof(void)
void do_uncut_text(void)
{
ssize_t was_lineno = openfile->current->lineno;
/* The line number where we started the paste. */
size_t was_leftedge = 0;
/* The leftedge where we started the paste. */
/* If the cutbuffer is empty, there is nothing to do. */
if (cutbuffer == NULL)
@@ -264,6 +269,9 @@ void do_uncut_text(void)
#ifndef NANO_TINY
add_undo(PASTE);
if (ISSET(SOFTWRAP))
was_leftedge = (xplustabs() / editwincols) * editwincols;
#endif
/* Add a copy of the text in the cutbuffer to the current filestruct
@@ -274,7 +282,8 @@ void do_uncut_text(void)
update_undo(PASTE);
#endif
if (openfile->current->lineno - was_lineno < editwinrows)
/* If we pasted less than a screenful, don't center the cursor. */
if (less_than_a_screenful(was_lineno, was_leftedge))
focusing = FALSE;
/* Set the desired x position to where the pasted text ends. */
@@ -286,8 +295,6 @@ void do_uncut_text(void)
/* Update the cursor position to account for the inserted lines. */
reset_cursor();
ensure_line_is_visible();
refresh_needed = TRUE;
#ifndef DISABLE_COLOR

View File

@@ -29,7 +29,9 @@
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#include <libgen.h>
#define LOCKBUFSIZE 8192
@@ -91,7 +93,6 @@ void make_new_buffer(void)
initialize_buffer_text();
openfile->current_x = 0;
openfile->placewewant = 0;
openfile->current_y = 0;
@@ -129,6 +130,8 @@ void initialize_buffer_text(void)
openfile->edittop = openfile->fileage;
openfile->current = openfile->fileage;
openfile->firstcolumn = 0;
openfile->current_x = 0;
openfile->totsize = 0;
}
@@ -146,13 +149,9 @@ void set_modified(void)
if (!ISSET(LOCKING) || openfile->filename[0] == '\0')
return;
if (openfile->lock_filename == NULL) {
/* TRANSLATORS: Keep the next ten messages at most 76 characters. */
// statusline(ALERT, _("Warning: Modifying a file which is not locked,"
// " check directory permission?"));
;
} else {
if (openfile->lock_filename != NULL) {
char *fullname = get_full_path(openfile->filename);
write_lockfile(openfile->lock_filename, fullname, TRUE);
free(fullname);
}
@@ -172,6 +171,7 @@ void set_modified(void)
* Returns 1 on success, and 0 on failure (but continue anyway). */
int write_lockfile(const char *lockfilename, const char *origfilename, bool modified)
{
#ifdef HAVE_PWD_H
int cflags, fd;
FILE *filestream;
pid_t mypid;
@@ -188,6 +188,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
/* First run things that might fail before blowing away the old state. */
if ((mypwuid = getpwuid(myuid)) == NULL) {
/* TRANSLATORS: Keep the next eight messages at most 76 characters. */
statusline(MILD, _("Couldn't determine my identity for lock file "
"(getpwuid() failed)"));
goto free_the_data;
@@ -287,6 +288,9 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
free_the_data:
free(lockdata);
return 0;
#else
return 1;
#endif
}
/* Delete the lockfile. Return -1 if unsuccessful, and 1 otherwise. */
@@ -548,6 +552,39 @@ void replace_buffer(const char *filename)
/* Put current at a place that is certain to exist. */
openfile->current = openfile->fileage;
}
#ifndef NANO_TINY
/* Open the specified file, and if that succeeds, blow away the text of
* the current buffer at the given coordinates and read the file
* contents into its place. */
void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x)
{
FILE *f;
int descriptor;
bool old_no_newlines = ISSET(NO_NEWLINES);
filestruct *trash_top = NULL;
filestruct *trash_bot = NULL;
descriptor = open_file(filename, FALSE, TRUE, &f);
if (descriptor < 0)
return;
/* Don't add a magicline when replacing text in the buffer. */
SET(NO_NEWLINES);
/* Throw away the text under the mark, and insert the processed file
* where the marked text was. */
extract_buffer(&trash_top, &trash_bot, top, top_x, bot, bot_x);
free_filestruct(trash_top);
read_file(f, descriptor, filename, FALSE, TRUE);
/* Restore the magicline behavior now that we're done fiddling. */
if (!old_no_newlines)
UNSET(NO_NEWLINES);
}
#endif /* !ENABLE_TINY */
#endif /* !DISABLE_SPELLER */
/* Update the screen to account for the current buffer. */
@@ -591,6 +628,14 @@ void switch_to_prevnext_buffer(bool to_next)
fprintf(stderr, "filename is %s\n", openfile->filename);
#endif
#ifndef NANO_TINY
/* When not in softwrap mode, make sure firstcolumn is zero. It might
* be nonzero if we had softwrap mode on while in this buffer, and then
* turned softwrap mode off while in a different buffer. */
if (!ISSET(SOFTWRAP))
openfile->firstcolumn = 0;
#endif
/* Update the screen to account for the current buffer. */
display_buffer();
@@ -686,44 +731,14 @@ int is_file_writable(const char *filename)
return result;
}
/* Make a new line of text from the given buf, which is of length buf_len.
* Then attach this line after prevnode. */
filestruct *read_line(char *buf, size_t buf_len, filestruct *prevnode)
/* Encode any NUL bytes in the given line of text, which is of length buf_len,
* and return a dynamically allocated copy of the resultant string. */
char *encode_data(char *buf, size_t buf_len)
{
filestruct *freshline = (filestruct *)nmalloc(sizeof(filestruct));
/* Convert nulls to newlines. buf_len is the string's real length. */
unsunder(buf, buf_len);
buf[buf_len] = '\0';
assert(openfile->fileage != NULL && strlen(buf) == buf_len);
#ifndef NANO_TINY
/* If file conversion isn't disabled, strip a '\r' from the line. */
if (buf_len > 0 && buf[buf_len - 1] == '\r' && !ISSET(NO_CONVERT))
buf[buf_len - 1] = '\0';
#endif
freshline->data = mallocstrcpy(NULL, buf);
#ifndef DISABLE_COLOR
freshline->multidata = NULL;
#endif
freshline->prev = prevnode;
if (prevnode == NULL) {
/* Special case: we're inserting into the first line. */
freshline->next = openfile->fileage;
openfile->fileage = freshline;
freshline->lineno = 1;
} else {
prevnode->next = freshline;
freshline->next = NULL;
freshline->lineno = prevnode->lineno + 1;
}
return freshline;
return mallocstrcpy(NULL, buf);
}
/* Read an open file into the current buffer. f should be set to the
@@ -734,6 +749,10 @@ filestruct *read_line(char *buf, size_t buf_len, filestruct *prevnode)
void read_file(FILE *f, int fd, const char *filename, bool undoable,
bool checkwritable)
{
ssize_t was_lineno = openfile->current->lineno;
/* The line number where we start the insertion. */
size_t was_leftedge = 0;
/* The leftedge where we start the insertion. */
size_t num_lines = 0;
/* The number of lines in the file. */
size_t len = 0;
@@ -744,8 +763,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
/* The buffer in which we assemble each line of the file. */
size_t bufx = MAX_BUF_SIZE;
/* The allocated size of the line buffer; increased as needed. */
filestruct *fileptr = openfile->current->prev;
/* The line after which to start inserting. */
filestruct *topline;
/* The top of the new buffer where we store the read file. */
filestruct *bottomline;
/* The bottom of the new buffer. */
int input_int;
/* The current value we read from the file, whether an input
* character or EOF. */
@@ -761,9 +782,16 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
#ifndef NANO_TINY
if (undoable)
add_undo(INSERT);
if (ISSET(SOFTWRAP))
was_leftedge = (xplustabs() / editwincols) * editwincols;
#endif
/* Read the entire file into the filestruct. */
/* Create an empty buffer. */
topline = make_new_node(NULL);
bottomline = topline;
/* Read the entire file into the new buffer. */
while ((input_int = getc(f)) != EOF) {
input = (char)input_int;
@@ -780,14 +808,6 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
if (format == 0 || format == 2)
format++;
}
#endif
/* Read in the line properly. */
fileptr = read_line(buf, len, fileptr);
num_lines++;
/* Reset the length in preparation for the next line. */
len = 0;
#ifndef NANO_TINY
/* If it's a Mac file ('\r' without '\n' on the first line if we
* think it's a *nix file, or on any line otherwise), and file
* conversion isn't disabled, handle it! */
@@ -798,15 +818,6 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
* set format to both DOS and Mac. */
if (format == 0 || format == 1)
format += 2;
/* Read in the line properly. */
fileptr = read_line(buf, len, fileptr);
num_lines++;
/* Store the character after the \r as the first character
* of the next line. */
buf[0] = input;
len = 1;
#endif
} else {
/* Store the character. */
@@ -822,7 +833,30 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
bufx += MAX_BUF_SIZE;
buf = charealloc(buf, bufx);
}
continue;
}
#ifndef NANO_TINY
/* If it's a DOS or Mac line, strip the '\r' from it. */
if (len > 0 && buf[len - 1] == '\r' && !ISSET(NO_CONVERT))
buf[--len] = '\0';
#endif
/* Store the data and make a new line. */
bottomline->data = encode_data(buf, len);
bottomline->next = make_new_node(bottomline);
bottomline = bottomline->next;
num_lines++;
/* Reset the length in preparation for the next line. */
len = 0;
#ifndef NANO_TINY
/* If it happens to be a Mac line, store the character after the \r
* as the first character of the next line. */
if (input != '\n')
buf[len++] = input;
#endif
}
/* Perhaps this could use some better handling. */
@@ -834,78 +868,43 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
writable = is_file_writable(filename);
}
/* Did we not get a newline and still have stuff to do? */
if (len > 0) {
/* If the file ended with newline, or it was entirely empty, make the
* last line blank. Otherwise, put the last read data in. */
if (len == 0)
bottomline->data = mallocstrcpy(NULL, "");
else {
bool mac_line_needs_newline = FALSE;
#ifndef NANO_TINY
/* If file conversion isn't disabled and the last character in
* this file is '\r', set format to Mac if we currently think
* the file is a *nix file, or to both DOS and Mac if we
* currently think the file is a DOS file. */
if (buf[len - 1] == '\r' && !ISSET(NO_CONVERT) && format < 2)
format += 2;
/* If the final character is '\r', and file conversion isn't disabled,
* set format to Mac if we currently think the file is a *nix file, or
* to DOS-and-Mac if we currently think it is a DOS file. */
if (buf[len - 1] == '\r' && !ISSET(NO_CONVERT)) {
if (format < 2)
format += 2;
/* Strip the carriage return. */
buf[--len] = '\0';
/* Indicate we need to put a blank line in after this one. */
mac_line_needs_newline = TRUE;
}
#endif
/* Read in the last line properly. */
fileptr = read_line(buf, len, fileptr);
/* Store the data of the final line. */
bottomline->data = encode_data(buf, len);
num_lines++;
if (mac_line_needs_newline) {
bottomline->next = make_new_node(bottomline);
bottomline = bottomline->next;
bottomline->data = mallocstrcpy(NULL, "");
}
}
free(buf);
/* Attach the file we got to the filestruct. If we got a file of
* zero bytes, don't do anything. */
if (num_lines > 0) {
/* If the file we got doesn't end in a newline (nor in a Mac return),
* tack its last line onto the beginning of the line at current. */
if (len > 0 && (input != '\r' || ISSET(NO_CONVERT))) {
filestruct *dropline = fileptr;
size_t current_len = strlen(openfile->current->data);
/* Adjust the current x-coordinate to compensate for the
* change in the current line. */
if (num_lines == 1)
openfile->current_x += len;
else
openfile->current_x = len;
/* Tack the text at fileptr onto the beginning of the text
* at current. */
openfile->current->data = charealloc(openfile->current->data,
len + current_len + 1);
charmove(openfile->current->data + len, openfile->current->data,
current_len + 1);
strncpy(openfile->current->data, fileptr->data, len);
/* Step back one line, and blow away the unterminated line,
* since its text has been copied into current. */
fileptr = fileptr->prev;
delete_node(dropline);
}
if (fileptr == NULL)
/* After inserting a single unterminated line at the top,
* readjust the top-of-file pointer. */
openfile->fileage = openfile->current;
else {
/* Attach the line at current after the line at fileptr. */
fileptr->next = openfile->current;
openfile->current->prev = fileptr;
}
/* Renumber, starting with the last line of the file we inserted. */
renumber(openfile->current);
}
openfile->totsize += get_totsize(openfile->fileage, openfile->filebot);
/* If the NO_NEWLINES flag isn't set, and text has been added to
* the magicline (i.e. a file that doesn't end in a newline has been
* inserted at the end of the current buffer), add a new magicline,
* and move the current line down to it. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0') {
new_magicline();
openfile->current = openfile->filebot;
openfile->current_x = 0;
}
/* Insert the just read buffer into the current one. */
ingraft_buffer(topline);
/* Set the desired x position at the end of what was inserted. */
openfile->placewewant = xplustabs();
@@ -934,7 +933,8 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
statusline(HUSH, P_("Read %lu line", "Read %lu lines",
(unsigned long)num_lines), (unsigned long)num_lines);
if (num_lines < editwinrows)
/* If we inserted less than a screenful, don't center the cursor. */
if (less_than_a_screenful(was_lineno, was_leftedge))
focusing = FALSE;
#ifndef NANO_TINY
@@ -1043,9 +1043,8 @@ char *get_next_filename(const char *name, const char *suffix)
sprintf(buf + wholenamelen, ".%lu", i);
}
/* We get here only if there is no possible save file. Blank out
* the filename to indicate this. */
null_at(&buf, 0);
/* There is no possible save file: blank out the filename. */
*buf = '\0';
return buf;
}
@@ -1059,7 +1058,7 @@ void do_insertfile(void)
char *given = mallocstrcpy(NULL, "");
/* The last answer the user typed at the statusbar prompt. */
#ifndef NANO_TINY
bool execute = FALSE, right_side_up = FALSE, single_line = FALSE;
bool execute = FALSE;
#endif
/* Display newlines in filenames as ^J. */
@@ -1080,10 +1079,10 @@ void do_insertfile(void)
{
#ifndef DISABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
msg = _("File to insert into new buffer [from %s] ");
msg = _("File to insert into new buffer [from %s]");
else
#endif
msg = _("File to insert [from %s] ");
msg = _("File to insert [from %s]");
}
present_path = mallocstrcpy(present_path, "./");
@@ -1098,8 +1097,7 @@ void do_insertfile(void)
#endif
edit_refresh, msg,
#ifndef DISABLE_OPERATINGDIR
operating_dir != NULL && strcmp(operating_dir, ".") != 0 ?
operating_dir :
operating_dir != NULL ? operating_dir :
#endif
"./");
@@ -1109,10 +1107,8 @@ void do_insertfile(void)
statusbar(_("Cancelled"));
break;
} else {
filestruct *edittop_save = openfile->edittop;
ssize_t was_current_lineno = openfile->current->lineno;
size_t was_current_x = openfile->current_x;
bool current_was_at_top = FALSE;
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
functionptrtype func = func_from_key(&i);
#endif
@@ -1152,29 +1148,6 @@ void do_insertfile(void)
if (i != 0 && (!ISSET(MULTIBUFFER) || i != -2))
continue;
#ifndef NANO_TINY
/* Keep track of whether the mark begins inside the
* partition and will need adjustment. */
if (openfile->mark_set) {
filestruct *top, *bot;
size_t top_x, bot_x;
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
single_line = (top == bot);
}
#endif
/* When not inserting into a new buffer, partition the filestruct
* so that it contains no text and hence looks like a new buffer,
* and remember whether the current line is the first on screen. */
if (!ISSET(MULTIBUFFER)) {
filepart = partition_filestruct(openfile->current,
openfile->current_x, openfile->current,
openfile->current_x);
current_was_at_top = (openfile->edittop == openfile->fileage);
}
#ifndef NANO_TINY
if (execute) {
#ifndef DISABLE_MULTIBUFFER
@@ -1223,57 +1196,6 @@ void do_insertfile(void)
} else
#endif /* !DISABLE_MULTIBUFFER */
{
filestruct *top_save = openfile->fileage;
/* If we were at the top of the edit window before, change the
* saved value of edittop to the start of inserted stuff. */
if (current_was_at_top)
edittop_save = openfile->fileage;
/* Update the current x-coordinate to account for the
* number of characters inserted on the current line.
* If the mark was positioned after the cursor and on the
* same line, adjust the mark's coordinates to compensate
* for the change in this line. */
openfile->current_x = strlen(openfile->filebot->data);
if (openfile->fileage == openfile->filebot) {
#ifndef NANO_TINY
if (openfile->mark_set) {
openfile->mark_begin = openfile->current;
if (!right_side_up)
openfile->mark_begin_x += openfile->current_x;
}
#endif
openfile->current_x += was_current_x;
}
#ifndef NANO_TINY
else if (openfile->mark_set) {
if (!right_side_up) {
if (single_line) {
openfile->mark_begin = openfile->current;
openfile->mark_begin_x -= was_current_x;
} else
openfile->mark_begin_x -= openfile->current_x;
}
}
#endif
/* Unpartition the filestruct so that it contains all
* the text again. Note that we've replaced the
* non-text originally in the partition with the text in
* the inserted file/executed command output. */
unpartition_filestruct(&filepart);
/* Renumber starting with the beginning line of the old
* partition. */
renumber(top_save);
/* Restore the old edittop. */
openfile->edittop = edittop_save;
/* Set the desired x position to the current one. */
openfile->placewewant = xplustabs();
/* Mark the file as modified if it changed. */
if (openfile->current->lineno != was_current_lineno ||
openfile->current_x != was_current_x)
@@ -1282,8 +1204,6 @@ void do_insertfile(void)
/* Update the cursor position to account for inserted lines. */
reset_cursor();
ensure_line_is_visible();
refresh_needed = TRUE;
}
@@ -1319,7 +1239,7 @@ char *get_full_path(const char *origpath)
/* How often we've tried climbing back up the tree. */
struct stat fileinfo;
char *currentdir, *d_here, *d_there, *d_there_file = NULL;
const char *last_slash;
char *last_slash;
bool path_only;
if (origpath == NULL)
@@ -1385,7 +1305,7 @@ char *get_full_path(const char *origpath)
d_there_file = mallocstrcpy(NULL, last_slash + 1);
/* Remove the filename portion of the answer from d_there. */
null_at(&d_there, last_slash - d_there + 1);
*(last_slash + 1) = '\0';
/* Go to the path specified in d_there. */
if (chdir(d_there) == -1) {
@@ -1521,7 +1441,7 @@ void init_operating_dir(void)
/* If the operating directory is inaccessible, fail. */
if (full_operating_dir == NULL || chdir(full_operating_dir) == -1)
die("Invalid operating directory\n");
die(_("Invalid operating directory\n"));
snuggly_fit(&full_operating_dir);
}
@@ -2442,6 +2362,7 @@ char *real_dir_from_tilde(const char *buf)
get_homedir();
tilde_dir = mallocstrcpy(NULL, homedir);
} else {
#ifdef HAVE_PWD_H
const struct passwd *userdata;
tilde_dir = mallocstrncpy(NULL, buf, i + 1);
@@ -2454,6 +2375,9 @@ char *real_dir_from_tilde(const char *buf)
endpwent();
if (userdata != NULL)
tilde_dir = mallocstrcpy(tilde_dir, userdata->pw_dir);
#else
tilde_dir = strdup("");
#endif
}
retval = charalloc(strlen(tilde_dir) + strlen(buf + i) + 1);
@@ -2544,12 +2468,14 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
size_t buf_len)
{
char **matches = NULL;
const struct passwd *userdata;
assert(buf != NULL && num_matches != NULL && buf_len > 0);
*num_matches = 0;
#ifdef HAVE_PWD_H
const struct passwd *userdata;
while ((userdata = getpwent()) != NULL) {
if (strncmp(userdata->pw_name, buf + 1, buf_len - 1) == 0) {
/* Cool, found a match. Add it to the list. This makes a
@@ -2570,6 +2496,7 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
}
}
endpwent();
#endif
return matches;
}
@@ -2587,7 +2514,7 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
const struct dirent *nextdir;
*num_matches = 0;
null_at(&dirname, buf_len);
dirname[buf_len] = '\0';
/* If there's a / in the name, split out filename and directory parts. */
slash = strrchr(dirname, '/');

View File

@@ -94,8 +94,6 @@ WINDOW *bottomwin;
* messages, the statusbar prompt, and a list of shortcuts. */
int editwinrows = 0;
/* How many rows does the edit window take up? */
int maxlines = 0;
/* How many file lines can be shown (due to soft wrapping). */
filestruct *cutbuffer = NULL;
/* The buffer where we store cut text. */
@@ -124,17 +122,12 @@ char *brackets = NULL;
* can end sentences. */
char *quotestr = NULL;
/* The quoting string. The default value is set in main(). */
#ifdef HAVE_REGEX_H
regex_t quotereg;
/* The compiled regular expression from the quoting string. */
int quoterc;
/* Whether it was compiled successfully. */
char *quoteerr = NULL;
/* The error message, if it didn't. */
#else
size_t quotelen;
/* The length of the quoting string in bytes. */
#endif
#endif /* !DISABLE_JUSTIFY */
char *word_chars = NULL;
@@ -212,13 +205,11 @@ poshiststruct *position_history = NULL;
/* The cursor position history list. */
#endif
#ifdef HAVE_REGEX_H
regex_t search_regexp;
/* The compiled regular expression to use in searches. */
regmatch_t regmatches[10];
/* The match positions for parenthetical subexpressions, 10
* maximum, used in regular expression searches. */
#endif
int hilite_attribute = A_REVERSE;
/* The curses attribute we use to highlight something. */
@@ -431,7 +422,7 @@ void assign_keyinfo(sc *s, const char *keystring, const int keycode)
if (strcasecmp(keystring, "M-Space") == 0)
s->keycode = (int)' ';
else
s->keycode = tolower((int)keystring[2]);
s->keycode = tolower((unsigned char)keystring[2]);
} else if (keystring[0] == 'F')
s->keycode = KEY_F0 + atoi(&keystring[1]);
else if (!strcasecmp(keystring, "Ins"))
@@ -508,8 +499,10 @@ void shortcut_init(void)
#ifndef DISABLE_BROWSER
const char *nano_browser_whereis_msg = N_("Search for a string");
const char *nano_browser_refresh_msg = N_("Refresh the file list");
#ifndef NANO_TINY
const char *nano_browser_lefthand_msg = N_("Go to lefthand column");
const char *nano_browser_righthand_msg = N_("Go to righthand column");
#endif
#endif
const char *nano_prevpage_msg = N_("Go one screenful up");
const char *nano_nextpage_msg = N_("Go one screenful down");
@@ -523,9 +516,9 @@ void shortcut_init(void)
#endif
const char *nano_replace_msg = N_("Replace a string or a regular expression");
const char *nano_gotoline_msg = N_("Go to line and column number");
const char *nano_whereis_next_msg = N_("Repeat the last search");
#ifndef NANO_TINY
const char *nano_mark_msg = N_("Mark text starting from the cursor position");
const char *nano_whereis_next_msg = N_("Repeat the last search");
const char *nano_copy_msg =
N_("Copy the current line and store it in the cutbuffer");
const char *nano_indent_msg = N_("Indent the current line");
@@ -598,15 +591,13 @@ void shortcut_init(void)
const char *nano_savefile_msg = N_("Save file without prompting");
const char *nano_findprev_msg = N_("Search next occurrence backward");
const char *nano_findnext_msg = N_("Search next occurrence forward");
#endif
const char *nano_case_msg =
N_("Toggle the case sensitivity of the search");
const char *nano_reverse_msg =
N_("Reverse the direction of the search");
#endif
#ifdef HAVE_REGEX_H
const char *nano_regexp_msg =
N_("Toggle the use of regular expressions");
#endif
#ifndef DISABLE_HISTORIES
const char *nano_prev_history_msg =
N_("Recall the previous search/replace string");
@@ -761,12 +752,22 @@ void shortcut_init(void)
gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
#endif
#ifndef NANO_TINY
add_to_funcs(do_undo, MMAIN,
N_("Undo"), IFSCHELP(nano_undo_msg), TOGETHER, NOVIEW);
add_to_funcs(do_redo, MMAIN,
N_("Redo"), IFSCHELP(nano_redo_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_mark, MMAIN,
N_("Mark Text"), IFSCHELP(nano_mark_msg), TOGETHER, VIEW);
add_to_funcs(do_copy_text, MMAIN,
N_("Copy Text"), IFSCHELP(nano_copy_msg), BLANKAFTER, NOVIEW);
#endif
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
N_("Case Sens"), IFSCHELP(nano_case_msg), TOGETHER, VIEW);
#ifdef HAVE_REGEX_H
add_to_funcs(regexp_void, MWHEREIS|MREPLACE,
N_("Regexp"), IFSCHELP(nano_regexp_msg), TOGETHER, VIEW);
#endif
add_to_funcs(backwards_void, MWHEREIS|MREPLACE,
N_("Backwards"), IFSCHELP(nano_reverse_msg), TOGETHER, VIEW);
@@ -784,45 +785,23 @@ void shortcut_init(void)
gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
#endif
add_to_funcs(do_page_up, MMAIN|MHELP,
prev_page_tag, IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
add_to_funcs(do_page_down, MMAIN|MHELP,
next_page_tag, IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
add_to_funcs(do_first_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("First Line"), IFSCHELP(nano_firstline_msg), TOGETHER, VIEW);
add_to_funcs(do_last_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("Last Line"), IFSCHELP(nano_lastline_msg), BLANKAFTER, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_find_bracket, MMAIN,
N_("To Bracket"), IFSCHELP(nano_bracket_msg), BLANKAFTER, VIEW);
add_to_funcs(do_research, MMAIN,
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
add_to_funcs(do_find_bracket, MMAIN,
N_("To Bracket"), IFSCHELP(nano_bracket_msg), TOGETHER, VIEW);
add_to_funcs(do_mark, MMAIN,
N_("Mark Text"), IFSCHELP(nano_mark_msg), TOGETHER, VIEW);
add_to_funcs(do_copy_text, MMAIN,
N_("Copy Text"), IFSCHELP(nano_copy_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_indent_void, MMAIN,
N_("Indent Text"), IFSCHELP(nano_indent_msg), TOGETHER, NOVIEW);
add_to_funcs(do_unindent, MMAIN,
N_("Unindent Text"), IFSCHELP(nano_unindent_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_undo, MMAIN,
N_("Undo"), IFSCHELP(nano_undo_msg), TOGETHER, NOVIEW);
add_to_funcs(do_redo, MMAIN,
N_("Redo"), IFSCHELP(nano_redo_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_findprevious, MMAIN,
N_("Previous"), IFSCHELP(nano_findprev_msg), TOGETHER, VIEW);
add_to_funcs(do_findnext, MMAIN,
N_("Next"), IFSCHELP(nano_findnext_msg), BLANKAFTER, VIEW);
#endif /* !NANO_TINY */
add_to_funcs(do_left, MMAIN,
N_("Back"), IFSCHELP(nano_back_msg), TOGETHER, VIEW);
add_to_funcs(do_right, MMAIN,
N_("Forward"), IFSCHELP(nano_forward_msg), TOGETHER, VIEW);
#ifndef DISABLE_BROWSER
add_to_funcs(do_left, MBROWSER,
N_("Back"), IFSCHELP(nano_backfile_msg), TOGETHER, VIEW);
@@ -835,28 +814,15 @@ void shortcut_init(void)
add_to_funcs(do_next_word_void, MMAIN,
N_("Next Word"), IFSCHELP(nano_nextword_msg), TOGETHER, VIEW);
add_to_funcs(do_home, MMAIN,
add_to_funcs(do_home_void, MMAIN,
N_("Home"), IFSCHELP(nano_home_msg), TOGETHER, VIEW);
add_to_funcs(do_end, MMAIN,
N_("End"), IFSCHELP(nano_end_msg), TOGETHER, VIEW);
add_to_funcs(do_end_void, MMAIN,
N_("End"), IFSCHELP(nano_end_msg), BLANKAFTER, VIEW);
add_to_funcs(do_up_void, MMAIN|MBROWSER,
prev_line_tag, IFSCHELP(nano_prevline_msg), TOGETHER, VIEW);
add_to_funcs(do_down_void, MMAIN|MBROWSER,
next_line_tag, IFSCHELP(nano_nextline_msg), BLANKAFTER, VIEW);
add_to_funcs(do_prev_block, MMAIN,
N_("Prev Block"), IFSCHELP(nano_prevblock_msg), TOGETHER, VIEW);
add_to_funcs(do_next_block, MMAIN,
N_("Next Block"), IFSCHELP(nano_nextblock_msg), TOGETHER, VIEW);
#ifndef DISABLE_JUSTIFY
add_to_funcs(do_para_begin_void, MMAIN|MWHEREIS,
N_("Beg of Par"), IFSCHELP(nano_parabegin_msg), TOGETHER, VIEW);
add_to_funcs(do_para_end_void, MMAIN|MWHEREIS,
N_("End of Par"), IFSCHELP(nano_paraend_msg), TOGETHER, VIEW);
#endif
next_line_tag, IFSCHELP(nano_nextline_msg), TOGETHER, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_scroll_up, MMAIN,
N_("Scroll Up"), IFSCHELP(nano_scrollup_msg), TOGETHER, VIEW);
@@ -864,6 +830,27 @@ void shortcut_init(void)
N_("Scroll Down"), IFSCHELP(nano_scrolldown_msg), BLANKAFTER, VIEW);
#endif
add_to_funcs(do_prev_block, MMAIN,
N_("Prev Block"), IFSCHELP(nano_prevblock_msg), TOGETHER, VIEW);
add_to_funcs(do_next_block, MMAIN,
N_("Next Block"), IFSCHELP(nano_nextblock_msg), TOGETHER, VIEW);
#ifndef DISABLE_JUSTIFY
add_to_funcs(do_para_begin_void, MMAIN|MWHEREIS,
N_("Beg of Par"), IFSCHELP(nano_parabegin_msg), TOGETHER, VIEW);
add_to_funcs(do_para_end_void, MMAIN|MWHEREIS,
N_("End of Par"), IFSCHELP(nano_paraend_msg), BLANKAFTER, VIEW);
#endif
add_to_funcs(do_page_up, MMAIN|MHELP,
prev_page_tag, IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
add_to_funcs(do_page_down, MMAIN|MHELP,
next_page_tag, IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
add_to_funcs(do_first_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("First Line"), IFSCHELP(nano_firstline_msg), TOGETHER, VIEW);
add_to_funcs(do_last_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("Last Line"), IFSCHELP(nano_lastline_msg), BLANKAFTER, VIEW);
#ifndef DISABLE_MULTIBUFFER
add_to_funcs(switch_to_prev_buffer_void, MMAIN,
N_("Prev File"), IFSCHELP(nano_prevfile_msg), TOGETHER, VIEW);
@@ -928,6 +915,12 @@ void shortcut_init(void)
add_to_funcs(do_suspend_void, MMAIN,
N_("Suspend"), IFSCHELP(nano_suspend_msg), BLANKAFTER, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_indent_void, MMAIN,
N_("Indent Text"), IFSCHELP(nano_indent_msg), TOGETHER, NOVIEW);
add_to_funcs(do_unindent, MMAIN,
N_("Unindent Text"), IFSCHELP(nano_unindent_msg), BLANKAFTER, NOVIEW);
#endif
#ifdef ENABLE_WORDCOMPLETION
add_to_funcs(complete_a_word, MMAIN,
N_("Complete"), IFSCHELP(nano_completion_msg), TOGETHER, NOVIEW);
@@ -939,11 +932,6 @@ void shortcut_init(void)
#ifndef NANO_TINY
add_to_funcs(do_savefile, MMAIN,
N_("Save"), IFSCHELP(nano_savefile_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_findprevious, MMAIN,
N_("Previous"), IFSCHELP(nano_findprev_msg), TOGETHER, VIEW);
add_to_funcs(do_findnext, MMAIN,
N_("Next"), IFSCHELP(nano_findnext_msg), BLANKAFTER, VIEW);
#endif
#ifndef DISABLE_HISTORIES
@@ -1018,11 +1006,9 @@ void shortcut_init(void)
add_to_funcs(discard_buffer, MWRITEFILE,
N_("Discard buffer"), IFSCHELP(nano_discard_buffer_msg), BLANKAFTER, NOVIEW);
#if !defined(NANO_TINY) && !defined(DISABLE_BROWSER)
#ifndef DISABLE_BROWSER
add_to_funcs(do_research, MBROWSER,
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
#endif
#ifndef DISABLE_BROWSER
add_to_funcs(total_refresh, MBROWSER,
refresh_tag, IFSCHELP(nano_browser_refresh_msg), BLANKAFTER, VIEW);
#ifndef NANO_TINY
@@ -1125,10 +1111,10 @@ void shortcut_init(void)
}
add_to_sclist(MMOST, "M-Space", 0, do_prev_word_void, 0);
add_to_sclist(MMOST, "^Space", 0, do_next_word_void, 0);
add_to_sclist((MMOST & ~MBROWSER), "^A", 0, do_home, 0);
add_to_sclist((MMOST & ~MBROWSER), "Home", KEY_HOME, do_home, 0);
add_to_sclist((MMOST & ~MBROWSER), "^E", 0, do_end, 0);
add_to_sclist((MMOST & ~MBROWSER), "End", KEY_END, do_end, 0);
add_to_sclist((MMOST & ~MBROWSER), "^A", 0, do_home_void, 0);
add_to_sclist((MMOST & ~MBROWSER), "Home", KEY_HOME, do_home_void, 0);
add_to_sclist((MMOST & ~MBROWSER), "^E", 0, do_end_void, 0);
add_to_sclist((MMOST & ~MBROWSER), "End", KEY_END, do_end_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", 0, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", KEY_UP, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", 0, do_down_void, 0);
@@ -1500,9 +1486,9 @@ sc *strtosc(const char *input)
!strcasecmp(input, "nextline"))
s->scfunc = do_down_void;
else if (!strcasecmp(input, "home"))
s->scfunc = do_home;
s->scfunc = do_home_void;
else if (!strcasecmp(input, "end"))
s->scfunc = do_end;
s->scfunc = do_end_void;
else if (!strcasecmp(input, "pageup") ||
!strcasecmp(input, "prevpage"))
s->scfunc = do_page_up;
@@ -1697,11 +1683,9 @@ void thanks_for_all_the_fish(void)
free(word_chars);
#ifndef DISABLE_JUSTIFY
free(quotestr);
#ifdef HAVE_REGEX_H
regfree(&quotereg);
free(quoteerr);
#endif
#endif
#ifndef NANO_TINY
free(backup_dir);
#endif

View File

@@ -486,6 +486,10 @@ functionptrtype parse_help_input(int *kbinput)
return do_page_up;
case 'E':
case 'e':
case 'Q':
case 'q':
case 'X':
case 'x':
return do_exit;
}
}

View File

@@ -44,47 +44,55 @@ void do_last_line(void)
/* Set the last line of the screen as the target for the cursor. */
openfile->current_y = editwinrows - 1;
ensure_line_is_visible();
refresh_needed = TRUE;
focusing = FALSE;
}
/* Move up one page. */
/* Determine the actual current chunk and the target column. */
void get_edge_and_target(size_t *leftedge, size_t *target_column)
{
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
size_t realspan = strlenpt(openfile->current->data);
if (openfile->placewewant < realspan)
realspan = openfile->placewewant;
*leftedge = (realspan / editwincols) * editwincols;
*target_column = openfile->placewewant % editwincols;
} else
#endif
{
*leftedge = 0;
*target_column = openfile->placewewant;
}
}
/* Move up nearly one screenful. */
void do_page_up(void)
{
int i, mustmove, skipped = 0;
/* If the cursor is less than a page away from the top of the file,
* put it at the beginning of the first line. */
if (openfile->current->lineno == 1 || (!ISSET(SOFTWRAP) &&
openfile->current->lineno <= editwinrows - 2)) {
do_first_line();
return;
}
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge, target_column;
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (!ISSET(SMOOTH_SCROLL)) {
openfile->current = openfile->edittop;
openfile->placewewant = openfile->current_y = 0;
openfile->placewewant = openfile->firstcolumn;
openfile->current_y = 0;
}
mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
get_edge_and_target(&leftedge, &target_column);
for (i = mustmove; i - skipped > 0 && openfile->current != openfile->fileage; i--) {
openfile->current = openfile->current->prev;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP) && openfile->current) {
skipped += strlenpt(openfile->current->data) / editwincols;
#ifdef DEBUG
fprintf(stderr, "paging up: i = %d, skipped = %d based on line %ld len %lu\n",
i, skipped, (long)openfile->current->lineno, (unsigned long)strlenpt(openfile->current->data));
#endif
}
#endif
/* Move up the required number of lines or chunks. If we can't, we're
* at the top of the file, so put the cursor there and get out. */
if (go_back_chunks(mustmove, &openfile->current, &leftedge) > 0) {
do_first_line();
return;
}
openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
@@ -93,35 +101,30 @@ void do_page_up(void)
refresh_needed = TRUE;
}
/* Move down one page. */
/* Move down nearly one screenful. */
void do_page_down(void)
{
int i, mustmove;
/* If the cursor is less than a page away from the bottom of the file,
* put it at the end of the last line. */
if (openfile->current->lineno + maxlines - 2 >= openfile->filebot->lineno) {
do_last_line();
return;
}
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge, target_column;
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (!ISSET(SMOOTH_SCROLL)) {
openfile->current = openfile->edittop;
openfile->placewewant = openfile->current_y = 0;
openfile->placewewant = openfile->firstcolumn;
openfile->current_y = 0;
}
mustmove = (maxlines < 3) ? 1 : maxlines - 2;
for (i = mustmove; i > 0 && openfile->current != openfile->filebot; i--) {
openfile->current = openfile->current->next;
#ifdef DEBUG
fprintf(stderr, "paging down: moving to line %lu\n", (unsigned long)openfile->current->lineno);
#endif
get_edge_and_target(&leftedge, &target_column);
/* Move down the required number of lines or chunks. If we can't, we're
* at the bottom of the file, so put the cursor there and get out. */
if (go_forward_chunks(mustmove, &openfile->current, &leftedge) > 0) {
do_last_line();
return;
}
openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
@@ -244,8 +247,6 @@ void do_prev_word(bool allow_punct, bool allow_update)
filestruct *was_current = openfile->current;
bool seen_a_word = FALSE, step_forward = FALSE;
assert(openfile->current != NULL && openfile->current->data != NULL);
/* Move backward until we pass over the start of a word. */
while (TRUE) {
/* If at the head of a line, move to the end of the preceding one. */
@@ -303,8 +304,6 @@ bool do_next_word(bool allow_punct, bool allow_update)
openfile->current_x, allow_punct);
bool seen_space = !started_on_word;
assert(openfile->current != NULL && openfile->current->data != NULL);
/* Move forward until we reach the start of a word. */
while (TRUE) {
/* If at the end of a line, move to the beginning of the next one. */
@@ -347,193 +346,216 @@ void do_next_word_void(void)
do_next_word(ISSET(WORD_BOUNDS), TRUE);
}
/* Make sure that the current line, when it is partially scrolled off the
* screen in softwrap mode, is scrolled fully into view. */
void ensure_line_is_visible(void)
{
#ifndef NANO_TINY
if (ISSET(SOFTWRAP) && strlenpt(openfile->current->data) / editwincols +
openfile->current_y >= editwinrows) {
adjust_viewport(ISSET(SMOOTH_SCROLL) ? FLOWING : CENTERING);
refresh_needed = TRUE;
}
#endif
}
/* Move to the beginning of the current line. If the SMART_HOME flag is
* set, move to the first non-whitespace character of the current line
* if we aren't already there, or to the beginning of the current line
* if we are. */
void do_home(void)
/* Move to the beginning of the current line (or softwrapped chunk).
* If be_clever is TRUE, do a smart home when wanted and possible,
* and do a dynamic home when in softwrap mode and it'spossible.
* If be_clever is FALSE, just do a simple home. */
void do_home(bool be_clever)
{
filestruct *was_current = openfile->current;
size_t was_column = xplustabs();
bool moved_off_chunk = TRUE;
#ifndef NANO_TINY
if (ISSET(SMART_HOME)) {
size_t current_x_save = openfile->current_x;
bool moved = FALSE;
size_t leftedge_x = 0;
openfile->current_x = indent_length(openfile->current->data);
if (ISSET(SOFTWRAP))
leftedge_x = actual_x(openfile->current->data,
(was_column / editwincols) * editwincols);
if (openfile->current_x == current_x_save ||
openfile->current->data[openfile->current_x] == '\0')
if (ISSET(SMART_HOME) && be_clever) {
size_t indent_x = indent_length(openfile->current->data);
if (openfile->current->data[indent_x] != '\0') {
/* If we're exactly on the indent, move fully home. Otherwise,
* when not softwrapping or not after the first nonblank chunk,
* move to the first nonblank character. */
if (openfile->current_x == indent_x) {
openfile->current_x = 0;
moved = TRUE;
} else if (!ISSET(SOFTWRAP) || leftedge_x <= indent_x) {
openfile->current_x = indent_x;
moved = TRUE;
}
}
}
if (!moved && ISSET(SOFTWRAP)) {
/* If already at the left edge of the screen, move fully home.
* Otherwise, move to the left edge. */
if (openfile->current_x == leftedge_x && be_clever)
openfile->current_x = 0;
} else
else {
openfile->current_x = leftedge_x;
moved_off_chunk = FALSE;
}
} else if (!moved)
#endif
openfile->current_x = 0;
openfile->placewewant = xplustabs();
if (need_horizontal_scroll(was_column, openfile->placewewant))
/* If we changed chunk, we might be offscreen. Otherwise,
* update current if the mark is on or we changed "page". */
if (ISSET(SOFTWRAP) && moved_off_chunk) {
focusing = FALSE;
edit_redraw(was_current);
} else if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}
/* Move to the end of the current line. */
void do_end(void)
/* Do a (smart or dynamic) home. */
void do_home_void(void)
{
size_t was_column = xplustabs();
do_home(TRUE);
}
/* Move to the end of the current line (or softwrapped chunk).
* If be_clever is TRUE, do a dynamic end when in softwrap mode and
* it's possible. If be_clever is FALSE, just do a simple end. */
void do_end(bool be_clever)
{
filestruct *was_current = openfile->current;
size_t was_column = xplustabs();
size_t line_len = strlen(openfile->current->data);
bool moved_off_chunk = TRUE;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
size_t rightedge_x = actual_x(openfile->current->data,
((was_column / editwincols) * editwincols) +
(editwincols - 1));
/* If already at the right edge of the screen, move fully to
* the end of the line. Otherwise, move to the right edge. */
if (openfile->current_x == rightedge_x && be_clever)
openfile->current_x = line_len;
else {
openfile->current_x = rightedge_x;
moved_off_chunk = FALSE;
}
} else
#endif
openfile->current_x = line_len;
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = xplustabs();
if (need_horizontal_scroll(was_column, openfile->placewewant))
/* If we changed chunk, we might be offscreen. Otherwise,
* update current if the mark is on or we changed "page". */
if (ISSET(SOFTWRAP) && moved_off_chunk) {
focusing = FALSE;
edit_redraw(was_current);
} else if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
ensure_line_is_visible();
}
/* If scroll_only is FALSE, move up one line. If scroll_only is TRUE,
* scroll up one line without scrolling the cursor. */
/* Do a (dynamic) end. */
void do_end_void(void)
{
do_end(TRUE);
}
/* Move the cursor to the preceding line or chunk. If scroll_only is TRUE,
* also scroll the screen one row, so the cursor stays in the same spot. */
void do_up(bool scroll_only)
{
filestruct *was_current = openfile->current;
size_t was_column = xplustabs();
size_t leftedge, target_column;
/* If we're at the top of the file, or if scroll_only is TRUE and
* the top of the file is onscreen, get out. */
if (openfile->current == openfile->fileage ||
(scroll_only && openfile->edittop == openfile->fileage))
/* When just scrolling and the top of the file is onscreen, get out. */
if (scroll_only && openfile->edittop == openfile->fileage &&
openfile->firstcolumn == 0)
return;
assert(ISSET(SOFTWRAP) || openfile->current_y == openfile->current->lineno - openfile->edittop->lineno);
get_edge_and_target(&leftedge, &target_column);
/* Move the current line of the edit window up. */
openfile->current = openfile->current->prev;
/* If we can't move up one line or chunk, we're at top of file. */
if (go_back_chunks(1, &openfile->current, &leftedge) > 0)
return;
openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
/* When the cursor was on the first line of the edit window (or when just
* scrolling without moving the cursor), scroll the edit window up -- one
* line if we're in smooth scrolling mode, and half a page otherwise. */
if (openfile->current->next == openfile->edittop || scroll_only)
if (openfile->current_y == 0 || scroll_only)
edit_scroll(UPWARD, (ISSET(SMOOTH_SCROLL) || scroll_only) ?
1 : editwinrows / 2 + 1);
/* If the lines weren't already redrawn, see if they need to be. */
if (openfile->current_y > 0) {
/* Redraw the prior line if it was horizontally scrolled. */
if (need_horizontal_scroll(was_column, 0))
/* Redraw the prior line if it's not offscreen, and it's not the same
* line as the current one, and the line was horizontally scrolled. */
if ((!scroll_only || openfile->current_y < editwinrows - 1) &&
openfile->current != was_current &&
line_needs_update(was_column, 0))
update_line(openfile->current->next, 0);
/* Redraw the current line if it needs to be horizontally scrolled. */
if (need_horizontal_scroll(0, xplustabs()))
if (line_needs_update(0, xplustabs()))
update_line(openfile->current, openfile->current_x);
}
}
/* Move up one line. */
/* Move up one line or chunk. */
void do_up_void(void)
{
do_up(FALSE);
}
/* If scroll_only is FALSE, move down one line. If scroll_only is TRUE,
* scroll down one line without scrolling the cursor. */
/* Move the cursor to next line or chunk. If scroll_only is TRUE, also
* scroll the screen one row, so the cursor stays in the same spot. */
void do_down(bool scroll_only)
{
#ifndef NANO_TINY
int amount = 0, enough;
filestruct *topline;
#endif
filestruct *was_current = openfile->current;
size_t was_column = xplustabs();
size_t leftedge, target_column;
/* If we're at the bottom of the file, get out. */
if (openfile->current == openfile->filebot)
get_edge_and_target(&leftedge, &target_column);
/* If we can't move down one line or chunk, we're at bottom of file. */
if (go_forward_chunks(1, &openfile->current, &leftedge) > 0)
return;
assert(ISSET(SOFTWRAP) || openfile->current_y ==
openfile->current->lineno - openfile->edittop->lineno);
assert(openfile->current->next != NULL);
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
/* Compute the number of lines to scroll. */
amount = strlenpt(openfile->current->data) / editwincols -
xplustabs() / editwincols +
strlenpt(openfile->current->next->data) / editwincols +
openfile->current_y - editwinrows + 2;
topline = openfile->edittop;
/* Reduce the amount when there are overlong lines at the top. */
for (enough = 1; enough < amount; enough++) {
amount -= strlenpt(topline->data) / editwincols;
if (amount > 0)
topline = topline->next;
if (amount < enough) {
amount = enough;
break;
}
}
}
#endif
/* Move to the next line in the file. */
openfile->current = openfile->current->next;
openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
/* When the cursor was on the last line of the edit window (or when just
* scrolling without moving the cursor), scroll the edit window down -- one
* line if we're in smooth scrolling mode, and half a page otherwise. */
#ifndef NANO_TINY
if (openfile->current_y == editwinrows - 1 || amount > 0 || scroll_only) {
if (amount < 1 || scroll_only)
amount = 1;
if (openfile->current_y == editwinrows - 1 || scroll_only)
edit_scroll(DOWNWARD, (ISSET(SMOOTH_SCROLL) || scroll_only) ?
amount : editwinrows / 2 + 1);
1 : editwinrows / 2 + 1);
if (ISSET(SOFTWRAP)) {
refresh_needed = TRUE;
return;
}
}
#else
if (openfile->current_y == editwinrows - 1)
edit_scroll(DOWNWARD, editwinrows / 2 + 1);
#endif
/* If the lines weren't already redrawn, see if they need to be. */
if (openfile->current_y < editwinrows - 1) {
/* Redraw the prior line if it was horizontally scrolled. */
if (need_horizontal_scroll(was_column, 0))
/* Redraw the prior line if it's not offscreen, and it's not the same
* line as the current one, and the line was horizontally scrolled. */
if ((!scroll_only || openfile->current_y > 0) &&
openfile->current != was_current &&
line_needs_update(was_column, 0))
update_line(openfile->current->prev, 0);
/* Redraw the current line if it needs to be horizontally scrolled. */
if (need_horizontal_scroll(0, xplustabs()))
if (line_needs_update(0, xplustabs()))
update_line(openfile->current, openfile->current_x);
}
}
/* Move down one line. */
/* Move down one line or chunk. */
void do_down_void(void)
{
do_down(FALSE);
}
#ifndef NANO_TINY
/* Scroll up one line without scrolling the cursor. */
/* Scroll up one line or chunk without scrolling the cursor. */
void do_scroll_up(void)
{
do_up(TRUE);
}
/* Scroll down one line without scrolling the cursor. */
/* Scroll down one line or chunk without scrolling the cursor. */
void do_scroll_down(void)
{
do_down(TRUE);
@@ -544,18 +566,35 @@ void do_scroll_down(void)
void do_left(void)
{
size_t was_column = xplustabs();
#ifndef NANO_TINY
size_t was_chunk = (was_column / editwincols);
filestruct *was_current = openfile->current;
#endif
if (openfile->current_x > 0)
openfile->current_x = move_mbleft(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->fileage) {
do_up_void();
openfile->current_x = strlen(openfile->current->data);
do_end(FALSE);
return;
}
openfile->placewewant = xplustabs();
if (need_horizontal_scroll(was_column, openfile->placewewant))
#ifndef NANO_TINY
/* If we were on the first line of the edit window, and we changed chunk,
* we're now above the first line of the edit window, so scroll up. */
if (ISSET(SOFTWRAP) && openfile->current_y == 0 &&
openfile->current == was_current &&
openfile->placewewant / editwincols != was_chunk) {
edit_scroll(UPWARD, ISSET(SMOOTH_SCROLL) ? 1 : editwinrows / 2 + 1);
return;
}
#endif
/* Update current if the mark is on or it has changed "page". */
if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}
@@ -563,27 +602,34 @@ void do_left(void)
void do_right(void)
{
size_t was_column = xplustabs();
assert(openfile->current_x <= strlen(openfile->current->data));
#ifndef NANO_TINY
size_t was_chunk = (was_column / editwincols);
filestruct *was_current = openfile->current;
#endif
if (openfile->current->data[openfile->current_x] != '\0')
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->filebot) {
openfile->current_x = 0;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->current_y -= strlenpt(openfile->current->data) / editwincols;
#endif
do_home(FALSE);
do_down_void();
return;
}
openfile->placewewant = xplustabs();
if (need_horizontal_scroll(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
#ifndef NANO_TINY
/* If we were on the last line of the edit window, and we changed chunk,
* we're now below the first line of the edit window, so scroll down. */
if (ISSET(SOFTWRAP) && openfile->current_y == editwinrows - 1 &&
openfile->current == was_current &&
openfile->placewewant / editwincols != was_chunk) {
edit_scroll(DOWNWARD, ISSET(SMOOTH_SCROLL) ? 1 : editwinrows / 2 + 1);
return;
}
#endif
if (openfile->current_x == 0)
do_down_void();
else
ensure_line_is_visible();
/* Update current if the mark is on or it has changed "page". */
if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}

View File

@@ -34,10 +34,10 @@
#ifdef ENABLE_UTF8
#include <langinfo.h>
#endif
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#include <getopt.h>
#ifndef NANO_TINY
#include <sys/ioctl.h>
#endif
@@ -50,7 +50,12 @@ static int oldinterval = -1;
static bool no_rcfiles = FALSE;
/* Should we ignore all rcfiles? */
#endif
#ifdef HAVE_TERMIOS_H
static struct termios oldterm;
#else
# define tcsetattr(...)
# define tcgetattr(...)
#endif
/* The user's original terminal settings. */
static struct sigaction act;
/* Used to set up all our fun signal handlers. */
@@ -223,7 +228,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
p->bot_data = mallocstrcpy(NULL, bot->data + bot_x);
/* Remove all text after bot_x at the bottom of the partition. */
null_at(&bot->data, bot_x);
bot->data[bot_x] = '\0';
/* Remove all text before top_x at the top of the partition. */
charmove(top->data, top->data + top_x, strlen(top->data) - top_x + 1);
@@ -746,32 +751,20 @@ void mouse_init(void)
}
#endif /* !DISABLE_MOUSE */
#ifdef HAVE_GETOPT_LONG
#define print_opt(shortflag, longflag, desc) print_opt_full(shortflag, longflag, desc)
#else
#define print_opt(shortflag, longflag, desc) print_opt_full(shortflag, desc)
#endif
/* Print one usage string to the screen. This cuts down on duplicate
* strings to translate, and leaves out the parts that shouldn't be
* translatable (i.e. the flag names). */
void print_opt_full(const char *shortflag
#ifdef HAVE_GETOPT_LONG
, const char *longflag
#endif
, const char *desc)
void print_opt(const char *shortflag, const char *longflag, const char *desc)
{
printf(" %s\t", shortflag);
if (strlenpt(shortflag) < 8)
printf("\t");
#ifdef HAVE_GETOPT_LONG
printf("%s\t", longflag);
if (strlenpt(longflag) < 8)
printf("\t\t");
else if (strlenpt(longflag) < 16)
printf("\t");
#endif
if (desc != NULL)
printf("%s", _(desc));
@@ -781,18 +774,18 @@ void print_opt_full(const char *shortflag
/* Explain how to properly use nano and its command-line options. */
void usage(void)
{
printf(_("Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]...\n\n"));
#ifdef HAVE_GETOPT_LONG
printf(_("Usage: nano [OPTIONS] [[+LINE[,COLUMN]] FILE]...\n\n"));
/* TRANSLATORS: The next two strings are part of the --help output.
* It's best to keep its lines within 80 characters. */
printf(_("To place the cursor on a specific line of a file, put the line number with\n"
"a '+' before the filename. The column number can be added after a comma.\n"));
printf(_("When the first filename is '-', nano reads data from standard input.\n\n"));
printf(_("Option\t\tGNU long option\t\tMeaning\n"));
#else
printf(_("Option\t\tMeaning\n"));
#endif
print_opt(_("+LINE,COLUMN"), "",
#ifndef NANO_TINY
print_opt("-A", "--smarthome",
/* TRANSLATORS: The next forty or so strings are option descriptions
* for the --help output. Try to keep them at most 40 characters. */
N_("Start at line LINE, column COLUMN"));
#ifndef NANO_TINY
print_opt("-A", "--smarthome", N_("Enable smart home key"));
N_("Enable smart home key"));
if (!ISSET(RESTRICTED)) {
print_opt("-B", "--backup", N_("Save backups of existing files"));
print_opt(_("-C <dir>"), _("--backupdir=<dir>"),
@@ -856,12 +849,16 @@ void usage(void)
#endif
#ifndef DISABLE_COLOR
if (!ISSET(RESTRICTED))
print_opt(_("-Y <str>"), _("--syntax=<str>"),
print_opt(_("-Y <name>"), _("--syntax=<name>"),
N_("Syntax definition to use for coloring"));
#endif
print_opt("-c", "--constantshow", N_("Constantly show cursor position"));
print_opt("-d", "--rebinddelete",
N_("Fix Backspace/Delete confusion problem"));
#ifndef DISABLE_BROWSER
if (!ISSET(RESTRICTED))
print_opt("-g", "--showcursor", N_("Show cursor in file browser"));
#endif
print_opt("-h", "--help", N_("Show this help text and exit"));
#ifndef NANO_TINY
print_opt("-i", "--autoindent", N_("Automatically indent new lines"));
@@ -1187,11 +1184,15 @@ void signal_init(void)
memset(&act, 0, sizeof(struct sigaction));
act.sa_handler = SIG_IGN;
sigaction(SIGINT, &act, NULL);
#ifdef SIGQUIT
sigaction(SIGQUIT, &act, NULL);
#endif
/* Trap SIGHUP and SIGTERM because we want to write the file out. */
act.sa_handler = handle_hupterm;
#ifdef SIGHUP
sigaction(SIGHUP, &act, NULL);
#endif
sigaction(SIGTERM, &act, NULL);
#ifndef NANO_TINY
@@ -1203,17 +1204,23 @@ void signal_init(void)
/* Trap normal suspend (^Z) so we can handle it ourselves. */
if (!ISSET(SUSPEND)) {
act.sa_handler = SIG_IGN;
#ifdef SIGTSTP
sigaction(SIGTSTP, &act, NULL);
#endif
} else {
/* Block all other signals in the suspend and continue handlers.
* If we don't do this, other stuff interrupts them! */
sigfillset(&act.sa_mask);
act.sa_handler = do_suspend;
#ifdef SIGTSTP
sigaction(SIGTSTP, &act, NULL);
#endif
act.sa_handler = do_continue;
#ifdef SIGCONT
sigaction(SIGCONT, &act, NULL);
#endif
}
}
@@ -1245,11 +1252,15 @@ RETSIGTYPE do_suspend(int signal)
/* Trap SIGHUP and SIGTERM so we can properly deal with them while
* suspended. */
act.sa_handler = handle_hupterm;
#ifdef SIGHUP
sigaction(SIGHUP, &act, NULL);
#endif
sigaction(SIGTERM, &act, NULL);
/* Do what mutt does: send ourselves a SIGSTOP. */
#ifdef SIGSTOP
kill(0, SIGSTOP);
#endif
}
/* The version of above function that is bound to a key. */
@@ -1321,6 +1332,9 @@ void regenerate_screen(void)
#endif
editwincols = COLS - margin;
/* Ensure that firstcolumn is the starting column of its chunk. */
ensure_firstcolumn_is_aligned();
#ifdef USE_SLANG
/* Slang curses emulation brain damage, part 1: If we just do what
* curses does here, it'll only work properly if the resize made the
@@ -1387,12 +1401,16 @@ void do_toggle(int flag)
case SUSPEND:
signal_init();
break;
case SOFTWRAP:
if (!ISSET(SOFTWRAP))
openfile->firstcolumn = 0;
refresh_needed = TRUE;
break;
case WHITESPACE_DISPLAY:
titlebar(NULL); /* Fall through. */
#ifndef DISABLE_COLOR
case NO_COLOR_SYNTAX:
#endif
case SOFTWRAP:
refresh_needed = TRUE;
break;
}
@@ -1417,23 +1435,27 @@ void do_toggle_void(void)
* settings. */
void disable_extended_io(void)
{
#ifdef HAVE_TERMIOS_H
struct termios term;
tcgetattr(0, &term);
term.c_lflag &= ~IEXTEN;
term.c_oflag &= ~OPOST;
tcsetattr(0, TCSANOW, &term);
#endif
}
/* Disable interpretation of the special control keys in our terminal
* settings. */
void disable_signals(void)
{
#ifdef HAVE_TERMIOS_H
struct termios term;
tcgetattr(0, &term);
term.c_lflag &= ~ISIG;
tcsetattr(0, TCSANOW, &term);
#endif
}
#ifndef NANO_TINY
@@ -1441,11 +1463,13 @@ void disable_signals(void)
* settings. */
void enable_signals(void)
{
#ifdef HAVE_TERMIOS_H
struct termios term;
tcgetattr(0, &term);
term.c_lflag |= ISIG;
tcsetattr(0, TCSANOW, &term);
#endif
}
#endif
@@ -1453,22 +1477,26 @@ void enable_signals(void)
* settings. */
void disable_flow_control(void)
{
#ifdef HAVE_TERMIOS_H
struct termios term;
tcgetattr(0, &term);
term.c_iflag &= ~IXON;
tcsetattr(0, TCSANOW, &term);
#endif
}
/* Enable interpretation of the flow control characters in our terminal
* settings. */
void enable_flow_control(void)
{
#ifdef HAVE_TERMIOS_H
struct termios term;
tcgetattr(0, &term);
term.c_iflag |= IXON;
tcsetattr(0, TCSANOW, &term);
#endif
}
/* Set up the terminal state. Put the terminal in raw mode (read one
@@ -1737,54 +1765,29 @@ int do_mouse(void)
bool sameline = (mouse_row == openfile->current_y);
/* Whether the click was on the row where the cursor is. */
filestruct *current_save = openfile->current;
ssize_t row_count = mouse_row - openfile->current_y;
size_t leftedge;
#ifndef NANO_TINY
size_t current_x_save = openfile->current_x;
if (ISSET(SOFTWRAP))
leftedge = (xplustabs() / editwincols) * editwincols;
else
#endif
leftedge = get_page_start(xplustabs());
#ifdef DEBUG
fprintf(stderr, "mouse_row = %d, current_y = %ld\n", mouse_row, (long)openfile->current_y);
#endif
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
ssize_t current_row = 0;
/* Move current up or down to the row corresponding to mouse_row. */
if (row_count < 0)
go_back_chunks(-row_count, &openfile->current, &leftedge);
else
go_forward_chunks(row_count, &openfile->current, &leftedge);
openfile->current = openfile->edittop;
while (openfile->current->next != NULL && current_row < mouse_row) {
current_row += strlenpt(openfile->current->data) / editwincols + 1;
openfile->current = openfile->current->next;
}
if (current_row > mouse_row) {
openfile->current = openfile->current->prev;
current_row -= strlenpt(openfile->current->data) / editwincols + 1;
openfile->current_x = actual_x(openfile->current->data,
((mouse_row - current_row) * editwincols) + mouse_col);
} else
openfile->current_x = actual_x(openfile->current->data, mouse_col);
openfile->current_y = current_row;
ensure_line_is_visible();
refresh_needed = TRUE;
} else
#endif /* NANO_TINY */
{
ssize_t current_row = openfile->current_y;
/* Move to where the click occurred. */
while (current_row < mouse_row && openfile->current->next != NULL) {
openfile->current = openfile->current->next;
current_row++;
}
while (current_row > mouse_row && openfile->current->prev != NULL) {
openfile->current = openfile->current->prev;
current_row--;
}
openfile->current_x = actual_x(openfile->current->data,
get_page_start(xplustabs()) + mouse_col);
}
openfile->current_x = actual_x(openfile->current->data,
leftedge + mouse_col);
#ifndef NANO_TINY
/* Clicking where the cursor is toggles the mark, as does clicking
@@ -1796,8 +1799,7 @@ int do_mouse(void)
/* The cursor moved; clean the cutbuffer on the next cut. */
cutbuffer_reset();
if (!ISSET(SOFTWRAP))
edit_redraw(current_save);
edit_redraw(current_save);
}
/* No more handling is needed. */
@@ -1810,18 +1812,18 @@ int do_mouse(void)
* TRUE. */
void do_output(char *output, size_t output_len, bool allow_cntrls)
{
size_t current_len, i = 0;
#ifndef NANO_TINY
size_t orig_rows = 0;
#endif
char *char_buf = charalloc(mb_cur_max());
int char_len;
current_len = strlen(openfile->current->data);
size_t current_len = strlen(openfile->current->data);
size_t i = 0;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
size_t orig_rows = 0, original_row = 0;
if (ISSET(SOFTWRAP)) {
if (openfile->current_y == editwinrows - 1)
original_row = xplustabs() / editwincols;
orig_rows = strlenpt(openfile->current->data) / editwincols;
}
#endif
while (i < output_len) {
@@ -1845,8 +1847,6 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
refresh_needed = TRUE;
}
assert(openfile->current_x <= current_len);
/* Make room for the new character and copy it into the line. */
openfile->current->data = charealloc(openfile->current->data,
current_len + char_len + 1);
@@ -1882,13 +1882,15 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
}
#ifndef NANO_TINY
ensure_line_is_visible();
/* If the number of screen rows that a softwrapped line occupies
* has changed, we need a full refresh. */
if (ISSET(SOFTWRAP) && refresh_needed == FALSE)
if ((strlenpt(openfile->current->data) / editwincols) != orig_rows)
refresh_needed = TRUE;
/* If the number of screen rows that a softwrapped line occupies has
* changed, we need a full refresh. And if we were on the last line
* of the edit window, and we moved one screen row, we're now below
* the last line of the edit window, so we need a full refresh too. */
if (ISSET(SOFTWRAP) && refresh_needed == FALSE &&
(strlenpt(openfile->current->data) / editwincols != orig_rows ||
(openfile->current_y == editwinrows - 1 &&
xplustabs() / editwincols != original_row)))
refresh_needed = TRUE;
#endif
free(char_buf);
@@ -1921,7 +1923,6 @@ int main(int argc, char **argv)
/* The old value of the multibuffer option, restored after we
* load all files on the command line. */
#endif
#ifdef HAVE_GETOPT_LONG
const struct option long_options[] = {
{"boldtext", 0, NULL, 'D'},
#ifndef DISABLE_MULTIBUFFER
@@ -1994,7 +1995,6 @@ int main(int argc, char **argv)
#endif
{NULL, 0, NULL, 0}
};
#endif
/* Back up the terminal settings so that they can be restored. */
tcgetattr(0, &oldterm);
@@ -2034,15 +2034,9 @@ int main(int argc, char **argv)
SET(RESTRICTED);
while ((optchr =
#ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv,
"ABC:DEFGHIKLNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxz$",
long_options, NULL)
#else
getopt(argc, argv,
"ABC:DEFGHIKLNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxz$")
#endif
) != -1) {
long_options, NULL)) != -1) {
switch (optchr) {
case 'a':
case 'b':
@@ -2417,14 +2411,7 @@ int main(int argc, char **argv)
/* If quotestr wasn't specified, set its default value. */
if (quotestr == NULL)
quotestr = mallocstrcpy(NULL,
#ifdef HAVE_REGEX_H
"^([ \t]*[#:>|}])+"
#else
"> "
#endif
);
#ifdef HAVE_REGEX_H
quotestr = mallocstrcpy(NULL, "^([ \t]*[#:>|}])+");
quoterc = regcomp(&quotereg, quotestr, NANO_REG_EXTENDED);
if (quoterc == 0) {
@@ -2437,9 +2424,6 @@ int main(int argc, char **argv)
quoteerr = charalloc(size);
regerror(quoterc, &quotereg, quoteerr, size);
}
#else
quotelen = strlen(quotestr);
#endif /* !HAVE_REGEX_H */
#endif /* !DISABLE_JUSTIFY */
#ifndef DISABLE_SPELLER
@@ -2545,7 +2529,7 @@ int main(int argc, char **argv)
shiftaltdown = get_keycode("kDN4", SHIFT_ALT_DOWN);
#endif
#ifndef USE_SLANG
#ifdef HAVE_SET_ESCDELAY
/* Tell ncurses to pass the Esc key quickly. */
set_escdelay(50);
#endif
@@ -2657,6 +2641,10 @@ int main(int argc, char **argv)
if (needed_margin != margin) {
margin = needed_margin;
editwincols = COLS - margin;
/* Ensure that firstcolumn is the starting column of its chunk. */
ensure_firstcolumn_is_aligned();
/* The margin has changed -- schedule a full refresh. */
refresh_needed = TRUE;
}
@@ -2671,7 +2659,7 @@ int main(int argc, char **argv)
/* Update the displayed current cursor position only when there
* are no keys waiting in the input buffer. */
if (ISSET(CONST_UPDATE) && get_key_buffer_len() == 0)
do_cursorpos(TRUE);
do_cursorpos(FALSE);
/* Refresh just the cursor position or the entire edit window. */
if (!refresh_needed) {

View File

@@ -49,9 +49,7 @@
#include <sys/param.h>
#endif
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
/* Suppress warnings for __attribute__((warn_unused_result)). */
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
@@ -116,46 +114,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#ifdef HAVE_REGEX_H
#include <regex.h>
#endif
#include <signal.h>
#include <assert.h>
/* If no vsnprintf(), use the version from glib 2.x. */
#ifndef HAVE_VSNPRINTF
#include <glib.h>
#define vsnprintf g_vsnprintf
#endif
/* If no isblank(), iswblank(), strcasecmp(), strncasecmp(),
* strcasestr(), strnlen(), getdelim(), or getline(), use the versions
* we have. */
#ifndef HAVE_ISBLANK
#define isblank nisblank
#endif
#ifndef HAVE_ISWBLANK
#define iswblank niswblank
#endif
#ifndef HAVE_STRCASECMP
#define strcasecmp nstrcasecmp
#endif
#ifndef HAVE_STRNCASECMP
#define strncasecmp nstrncasecmp
#endif
#ifndef HAVE_STRCASESTR
#define strcasestr nstrcasestr
#endif
#ifndef HAVE_STRNLEN
#define strnlen nstrnlen
#endif
#ifndef HAVE_GETDELIM
#define getdelim ngetdelim
#endif
#ifndef HAVE_GETLINE
#define getline ngetline
#endif
/* If we aren't using ncurses with mouse support, turn the mouse support
* off, as it's useless then. */
#ifndef NCURSES_MOUSE_VERSION
@@ -391,6 +353,9 @@ typedef struct openfilestruct {
/* The current line for this file. */
size_t totsize;
/* The file's total number of characters. */
size_t firstcolumn;
/* The starting column of the top line of the edit window.
* When not in softwrap mode, it's always zero. */
size_t current_x;
/* The file's x-coordinate position. */
size_t placewewant;
@@ -547,7 +512,8 @@ enum
MAKE_IT_UNIX,
JUSTIFY_TRIM,
SHOW_CURSOR,
LINE_NUMBERS
LINE_NUMBERS,
NO_PAUSES
};
/* Flags for the menus in which a given function should be present. */

View File

@@ -125,9 +125,9 @@ int do_statusbar_input(bool *ran_func, bool *finished)
else if (s->scfunc == do_next_word_void)
do_statusbar_next_word();
#endif
else if (s->scfunc == do_home)
else if (s->scfunc == do_home_void)
do_statusbar_home();
else if (s->scfunc == do_end)
else if (s->scfunc == do_end_void)
do_statusbar_end();
/* When in restricted mode at the "Write File" prompt and the
* filename isn't blank, disallow any input and deletion. */
@@ -296,7 +296,7 @@ void do_statusbar_cut_text(void)
if (!ISSET(CUT_TO_END))
statusbar_x = 0;
null_at(&answer, statusbar_x);
answer[statusbar_x] = '\0';
update_the_statusbar();
}
@@ -637,7 +637,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
vsnprintf(prompt, COLS * mb_cur_max(), msg, ap);
va_end(ap);
/* Reserve five columns for colon plus angles plus answer, ":<aa>". */
null_at(&prompt, actual_x(prompt, (COLS < 5) ? 0 : COLS - 5));
prompt[actual_x(prompt, (COLS < 5) ? 0 : COLS - 5)] = '\0';
func = acquire_an_answer(&retval, allow_tabs, allow_files, &listed,
#ifndef DISABLE_HISTORIES

View File

@@ -76,7 +76,6 @@ extern WINDOW *topwin;
extern WINDOW *edit;
extern WINDOW *bottomwin;
extern int editwinrows;
extern int maxlines;
extern filestruct *cutbuffer;
extern filestruct *cutbottom;
@@ -100,13 +99,9 @@ extern const char *unjust_tag;
extern char *punct;
extern char *brackets;
extern char *quotestr;
#ifdef HAVE_REGEX_H
extern regex_t quotereg;
extern int quoterc;
extern char *quoteerr;
#else
extern size_t quotelen;
#endif
#endif /* !DISABLE_JUSTIFY */
extern char *word_chars;
@@ -154,10 +149,8 @@ extern filestruct *replacebot;
extern poshiststruct *position_history;
#endif
#ifdef HAVE_REGEX_H
extern regex_t search_regexp;
extern regmatch_t regmatches[10];
#endif
extern int hilite_attribute;
#ifndef DISABLE_COLOR
@@ -184,7 +177,7 @@ void do_filesearch(void);
void do_fileresearch(void);
void do_first_file(void);
void do_last_file(void);
char *striponedir(const char *path);
char *strip_last_component(const char *path);
#endif
/* Most functions in chars.c. */
@@ -193,12 +186,6 @@ void utf8_init(void);
bool using_utf8(void);
#endif
char *addstrings(char* str1, size_t len1, char* str2, size_t len2);
#ifndef HAVE_ISBLANK
bool nisblank(int c);
#endif
#if !defined(HAVE_ISWBLANK) && defined(ENABLE_UTF8)
bool niswblank(wchar_t wc);
#endif
bool is_byte(int c);
bool is_alpha_mbchar(const char *c);
bool is_alnum_mbchar(const char *c);
@@ -217,17 +204,8 @@ char *make_mbchar(long chr, int *chr_mb_len);
int parse_mbchar(const char *buf, char *chr, size_t *col);
size_t move_mbleft(const char *buf, size_t pos);
size_t move_mbright(const char *buf, size_t pos);
#ifndef HAVE_STRCASECMP
int nstrcasecmp(const char *s1, const char *s2);
#endif
int mbstrcasecmp(const char *s1, const char *s2);
#ifndef HAVE_STRNCASECMP
int nstrncasecmp(const char *s1, const char *s2, size_t n);
#endif
int mbstrncasecmp(const char *s1, const char *s2, size_t n);
#ifndef HAVE_STRCASESTR
char *nstrcasestr(const char *haystack, const char *needle);
#endif
char *mbstrcasestr(const char *haystack, const char *needle);
char *revstrstr(const char *haystack, const char *needle,
const char *pointer);
@@ -236,9 +214,6 @@ char *revstrcasestr(const char *haystack, const char *needle, const char
char *mbrevstrcasestr(const char *haystack, const char *needle, const
char *rev_start);
size_t mbstrlen(const char *s);
#ifndef HAVE_STRNLEN
size_t nstrnlen(const char *s, size_t maxlen);
#endif
size_t mbstrnlen(const char *s, size_t maxlen);
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
char *mbstrchr(const char *s, const char *c);
@@ -294,6 +269,10 @@ void initialize_buffer_text(void);
bool open_buffer(const char *filename, bool undoable);
#ifndef DISABLE_SPELLER
void replace_buffer(const char *filename);
#ifndef NANO_TINY
void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x);
#endif
#endif
void display_buffer(void);
#ifndef DISABLE_MULTIBUFFER
@@ -301,7 +280,7 @@ void switch_to_prev_buffer_void(void);
void switch_to_next_buffer_void(void);
bool close_buffer(void);
#endif
filestruct *read_line(char *buf, size_t buf_len, filestruct *prevnode);
char *encode_data(char *buf, size_t buf_len);
void read_file(FILE *f, int fd, const char *filename, bool undoable,
bool checkwritable);
int open_file(const char *filename, bool newfie, bool quiet, FILE **f);
@@ -404,9 +383,10 @@ void do_prev_word(bool allow_punct, bool allow_update);
void do_prev_word_void(void);
bool do_next_word(bool allow_punct, bool allow_update);
void do_next_word_void(void);
void ensure_line_is_visible(void);
void do_home(void);
void do_end(void);
void do_home(bool be_clever);
void do_home_void(void);
void do_end(bool be_clever);
void do_end_void(void);
void do_up(bool scroll_only);
void do_up_void(void);
void do_down(bool scroll_only);
@@ -451,11 +431,7 @@ void disable_mouse_support(void);
void enable_mouse_support(void);
void mouse_init(void);
#endif
void print_opt_full(const char *shortflag
#ifdef HAVE_GETOPT_LONG
, const char *longflag
#endif
, const char *desc);
void print_opt(const char *shortflag, const char *longflag, const char *desc);
void usage(void);
void version(void);
void do_exit(void);
@@ -527,10 +503,8 @@ void do_rcfiles(void);
#endif /* !DISABLE_NANORC */
/* All functions in search.c. */
#ifdef HAVE_REGEX_H
bool regexp_init(const char *regexp);
void regexp_cleanup(void);
#endif
void not_found_msg(const char *str);
void search_replace_abort(void);
int search_init(bool replacing, bool use_answer);
@@ -543,9 +517,7 @@ void do_findnext(void);
#endif
void do_research(void);
void go_looking(void);
#ifdef HAVE_REGEX_H
int replace_regexp(char *string, bool create);
#endif
char *replace_line(const char *needle);
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
const filestruct *real_current, size_t *real_current_x);
@@ -613,11 +585,7 @@ void wrap_reset(void);
bool do_wrap(filestruct *line);
#endif
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
ssize_t break_line(const char *line, ssize_t goal
#ifndef DISABLE_HELP
, bool newln
#endif
);
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
#endif
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
size_t indent_length(const char *line);
@@ -664,17 +632,7 @@ void snuggly_fit(char **str);
void null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len);
void sunder(char *str);
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef HAVE_GETLINE
ssize_t ngetline(char **lineptr, size_t *n, FILE *stream);
#endif
#ifndef HAVE_GETDELIM
ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream);
#endif
#endif
#ifdef HAVE_REGEX_H
const char *fixbounds(const char *r);
#endif
#ifndef DISABLE_SPELLER
bool is_separate_word(size_t position, size_t length, const char *buf);
#endif
@@ -748,15 +706,25 @@ void reset_cursor(void);
void edit_draw(filestruct *fileptr, const char *converted,
int line, size_t from_col);
int update_line(filestruct *fileptr, size_t index);
bool need_horizontal_scroll(const size_t old_column, const size_t new_column);
#ifndef NANO_TINY
int update_softwrapped_line(filestruct *fileptr);
#endif
bool line_needs_update(const size_t old_column, const size_t new_column);
int go_back_chunks(int nrows, filestruct **line, size_t *leftedge);
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);
void edit_scroll(scroll_dir direction, int nrows);
void ensure_firstcolumn_is_aligned(void);
bool current_is_above_screen(void);
bool current_is_below_screen(void);
bool current_is_offscreen(void);
void edit_redraw(filestruct *old_current);
void edit_refresh(void);
void adjust_viewport(update_type location);
void total_redraw(void);
void total_refresh(void);
void display_main_list(void);
void do_cursorpos(bool constant);
void do_cursorpos(bool force);
void do_cursorpos_void(void);
void spotlight(bool active, const char *word);
void xon_complaint(void);

View File

@@ -62,6 +62,7 @@ static const rcoption rcopts[] = {
#endif
{"nohelp", NO_HELP},
{"nonewlines", NO_NEWLINES},
{"nopauses", NO_PAUSES},
#ifndef DISABLE_WRAPPING
{"nowrap", NO_WRAP},
#endif
@@ -79,9 +80,7 @@ static const rcoption rcopts[] = {
#endif
{"rebinddelete", REBIND_DELETE},
{"rebindkeypad", REBIND_KEYPAD},
#ifdef HAVE_REGEX_H
{"regexp", USE_REGEXP},
#endif
#ifndef DISABLE_SPELLER
{"speller", 0},
#endif
@@ -169,7 +168,7 @@ void rcfile_error(const char *msg, ...)
* returned pointer will point to '\0' if we hit the end of the line. */
char *parse_next_word(char *ptr)
{
while (!isblank(*ptr) && *ptr != '\0')
while (!isblank((unsigned char)*ptr) && *ptr != '\0')
ptr++;
if (*ptr == '\0')
@@ -178,7 +177,7 @@ char *parse_next_word(char *ptr)
/* Null-terminate and advance ptr. */
*ptr++ = '\0';
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
return ptr;
@@ -217,7 +216,7 @@ char *parse_argument(char *ptr)
ptr = last_quote + 1;
}
if (ptr != NULL)
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
return ptr;
}
@@ -232,7 +231,7 @@ char *parse_next_regex(char *ptr)
/* Continue until the end of line, or until a " followed by a
* blank character or the end of line. */
while (*ptr != '\0' && (*ptr != '"' ||
(*(ptr + 1) != '\0' && !isblank(*(ptr + 1)))))
(*(ptr + 1) != '\0' && !isblank((unsigned char)ptr[1]))))
ptr++;
assert(*ptr == '"' || *ptr == '\0');
@@ -246,7 +245,7 @@ char *parse_next_regex(char *ptr)
/* Null-terminate and advance ptr. */
*ptr++ = '\0';
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
return ptr;
@@ -351,7 +350,7 @@ void parse_syntax(char *ptr)
bool is_universal(void (*func))
{
if (func == do_left || func == do_right ||
func == do_home || func == do_end ||
func == do_home_void || func == do_end_void ||
func == do_prev_word_void || func == do_next_word_void ||
func == do_verbatim_input || func == do_cut_text_void ||
func == do_delete || func == do_backspace ||
@@ -389,11 +388,11 @@ void parse_binding(char *ptr, bool dobind)
}
/* Uppercase only the first two or three characters of the key name. */
keycopy[0] = toupper(keycopy[0]);
keycopy[1] = toupper(keycopy[1]);
keycopy[0] = toupper((unsigned char)keycopy[0]);
keycopy[1] = toupper((unsigned char)keycopy[1]);
if (keycopy[0] == 'M' && keycopy[1] == '-') {
if (strlen(keycopy) > 2)
keycopy[2] = toupper(keycopy[2]);
keycopy[2] = toupper((unsigned char)keycopy[2]);
else {
rcfile_error(N_("Key name is too short"));
goto free_copy;
@@ -403,7 +402,7 @@ void parse_binding(char *ptr, bool dobind)
/* Allow the codes for Insert and Delete to be rebound, but apart
* from those two only Control, Meta and Function sequences. */
if (!strcasecmp(keycopy, "Ins") || !strcasecmp(keycopy, "Del"))
keycopy[1] = tolower(keycopy[1]);
keycopy[1] = tolower((unsigned char)keycopy[1]);
else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') {
rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\""));
goto free_copy;
@@ -968,7 +967,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
lineno++;
ptr = buf;
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
/* If we have a blank line or a comment, skip to the next
@@ -1294,7 +1293,7 @@ void do_rcfiles(void)
free(nanorc);
if (errors && !ISSET(QUIET)) {
if (errors && !ISSET(QUIET) && !ISSET(NO_PAUSES)) {
errors = FALSE;
fprintf(stderr, _("\nPress Enter to continue starting nano.\n"));
while (getchar() != '\n')

View File

@@ -35,7 +35,6 @@ static bool came_full_circle = FALSE;
static bool history_changed = FALSE;
/* Have any of the history lists changed? */
#endif
#ifdef HAVE_REGEX_H
static bool regexp_compiled = FALSE;
/* Have we compiled any regular expressions? */
@@ -72,7 +71,6 @@ void regexp_cleanup(void)
regfree(&search_regexp);
}
}
#endif
/* Indicate on the statusbar that the string at str was not found by the
* last search. */
@@ -102,9 +100,7 @@ void search_replace_abort(void)
if (openfile->mark_set)
refresh_needed = TRUE;
#endif
#ifdef HAVE_REGEX_H
regexp_cleanup();
#endif
}
/* Set up the system variables for a search or replace. If use_answer
@@ -156,10 +152,7 @@ int search_init(bool replacing, bool use_answer)
edit_refresh, "%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next three modify the search prompt. */
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
#ifdef HAVE_REGEX_H
ISSET(USE_REGEXP) ? _(" [Regexp]") :
#endif
"",
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
#ifndef NANO_TINY
/* TRANSLATORS: The next two modify the search prompt. */
@@ -189,11 +182,9 @@ int search_init(bool replacing, bool use_answer)
update_history(&search_history, answer);
#endif
}
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
return -1;
else
#endif
return 0; /* We have a valid string or regex. */
}
@@ -207,15 +198,11 @@ int search_init(bool replacing, bool use_answer)
TOGGLE(BACKWARDS_SEARCH);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else
#ifdef HAVE_REGEX_H
if (func == regexp_void) {
} else if (func == regexp_void) {
TOGGLE(USE_REGEXP);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else
#endif
if (func == do_replace || func == flip_replace_void) {
} else if (func == do_replace || func == flip_replace_void) {
backupstring = mallocstrcpy(backupstring, answer);
return -2; /* Call the opposite search function. */
} else if (func == do_gotolinecolumn_void) {
@@ -297,11 +284,9 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
}
if (found != NULL) {
#ifdef HAVE_REGEX_H
/* When doing a regex search, compute the length of the match. */
if (ISSET(USE_REGEXP))
found_len = regmatches[0].rm_eo - regmatches[0].rm_so;
#endif
#ifndef DISABLE_SPELLER
/* When we're spell checking, a match should be a separate word;
* if it's not, continue looking in the rest of the line. */
@@ -438,10 +423,8 @@ void do_research(void)
return;
}
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
return;
#endif
/* Use the search-menu key bindings, to allow cancelling. */
currmenu = MWHEREIS;
@@ -479,7 +462,6 @@ void go_looking(void)
search_replace_abort();
}
#ifdef HAVE_REGEX_H
/* Calculate the size of the replacement text, taking possible
* subexpressions \1 to \9 into account. Return the replacement
* text in the passed string only when create is TRUE. */
@@ -522,7 +504,6 @@ int replace_regexp(char *string, bool create)
return replacement_size;
}
#endif /* HAVE_REGEX_H */
/* Return a copy of the current line with one needle replaced. */
char *replace_line(const char *needle)
@@ -532,17 +513,13 @@ char *replace_line(const char *needle)
size_t new_line_size = strlen(openfile->current->data) + 1;
/* First adjust the size of the new line for the change. */
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) {
match_len = regmatches[0].rm_eo - regmatches[0].rm_so;
new_line_size += replace_regexp(NULL, FALSE) - match_len;
} else {
#endif
match_len = strlen(needle);
new_line_size += strlen(answer) - match_len;
#ifdef HAVE_REGEX_H
}
#endif
/* Create the buffer. */
copy = charalloc(new_line_size);
@@ -551,11 +528,9 @@ char *replace_line(const char *needle)
strncpy(copy, openfile->current->data, openfile->current_x);
/* Add the replacement text. */
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
replace_regexp(copy + openfile->current_x, TRUE);
else
#endif
strcpy(copy + openfile->current_x, answer);
assert(openfile->current_x + match_len <= strlen(openfile->current->data));
@@ -706,11 +681,10 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
#endif
}
#ifdef HAVE_REGEX_H
/* Don't find the same zero-length or BOL match again. */
if (match_len == 0 || (*needle == '^' && ISSET(USE_REGEXP)))
skipone = TRUE;
#endif
/* When moving forward, put the cursor just after the replacement
* text, so that searching will continue there. */
if (!ISSET(BACKWARDS_SEARCH))
@@ -762,7 +736,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
void do_replace(void)
{
filestruct *edittop_save, *begin;
size_t begin_x;
size_t firstcolumn_save, begin_x;
ssize_t numreplaced;
int i;
@@ -806,6 +780,7 @@ void do_replace(void)
/* Save where we are. */
edittop_save = openfile->edittop;
firstcolumn_save = openfile->firstcolumn;
begin = openfile->current;
begin_x = openfile->current_x;
@@ -813,6 +788,7 @@ void do_replace(void)
/* Restore where we were. */
openfile->edittop = edittop_save;
openfile->firstcolumn = firstcolumn_save;
openfile->current = begin;
openfile->current_x = begin_x;
refresh_needed = TRUE;
@@ -909,17 +885,29 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
openfile->placewewant = column - 1;
/* When the position was manually given, center the target line. */
if (interactive || ISSET(SOFTWRAP)) {
if (interactive) {
adjust_viewport(CENTERING);
refresh_needed = TRUE;
} else {
int rows_from_tail;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
filestruct *line = openfile->current;
size_t leftedge = (xplustabs() / editwincols) * editwincols;
rows_from_tail = (editwinrows / 2) -
go_forward_chunks(editwinrows / 2, &line, &leftedge);
} else
#endif
rows_from_tail = openfile->filebot->lineno -
openfile->current->lineno;
/* If the target line is close to the tail of the file, put the last
* line of the file on the bottom line of the screen; otherwise, just
* line or chunk on the bottom line of the screen; otherwise, just
* center the target line. */
if (openfile->filebot->lineno - openfile->current->lineno <
editwinrows / 2) {
openfile->current_y = editwinrows - openfile->filebot->lineno +
openfile->current->lineno - 1;
if (rows_from_tail < editwinrows / 2) {
openfile->current_y = editwinrows - 1 - rows_from_tail;
adjust_viewport(STATIONARY);
} else
adjust_viewport(CENTERING);
@@ -1072,7 +1060,7 @@ void do_find_bracket(void)
bracket_set = charalloc((mb_cur_max() * 2) + 1);
strncpy(bracket_set, ch, ch_len);
strncpy(bracket_set + ch_len, wanted_ch, wanted_ch_len);
null_at(&bracket_set, ch_len + wanted_ch_len);
bracket_set[ch_len + wanted_ch_len] = '\0';
found_ch = charalloc(mb_cur_max() + 1);

View File

@@ -179,13 +179,11 @@ void do_deletion(undo_type action)
return;
#ifndef NANO_TINY
ensure_line_is_visible();
/* If the number of screen rows that a softwrapped line occupies
* has changed, we need a full refresh. */
if (ISSET(SOFTWRAP) && refresh_needed == FALSE)
if ((strlenpt(openfile->current->data) / editwincols) != orig_rows)
refresh_needed = TRUE;
if (ISSET(SOFTWRAP) && refresh_needed == FALSE &&
strlenpt(openfile->current->data) / editwincols != orig_rows)
refresh_needed = TRUE;
#endif
set_modified();
@@ -791,10 +789,7 @@ void do_undo(void)
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
cutbuffer = NULL;
cutbottom = NULL;
/* Instead of a line number, u->mark_begin_lineno contains the number
* of lines of the inserted segment, because the file was partitioned
* when update_undo() was called; so, calculate the end-line number. */
openfile->mark_begin = fsfromline(u->lineno + u->mark_begin_lineno - 1);
openfile->mark_begin = fsfromline(u->mark_begin_lineno);
openfile->mark_begin_x = u->mark_begin_x;
openfile->mark_set = TRUE;
goto_line_posx(u->lineno, u->begin);
@@ -855,7 +850,7 @@ void do_redo(void)
return;
}
f = fsfromline(u->type == INSERT ? 1 : u->mark_begin_lineno);
f = fsfromline(u->mark_begin_lineno);
if (!f)
return;
@@ -1229,7 +1224,7 @@ void add_undo(undo_type action)
char *char_buf = charalloc(mb_cur_max() + 1);
int char_len = parse_mbchar(&openfile->current->data[u->begin],
char_buf, NULL);
null_at(&char_buf, char_len);
char_buf[char_len] = '\0';
u->strdata = char_buf;
if (u->type == BACK)
u->mark_begin_x += char_len;
@@ -1434,14 +1429,8 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
u->lineno = openfile->current->lineno;
break;
case INSERT:
/* Store the number of lines (plus one) of the insertion. */
u->mark_begin_lineno = openfile->current->lineno;
/* When the insertion contains no newline, store the adjusted
* x position; otherwise, store the length of the last line. */
if (openfile->fileage == openfile->filebot)
u->mark_begin_x = openfile->current_x;
else
u->mark_begin_x = strlen(openfile->filebot->data);
u->mark_begin_x = openfile->current_x;
break;
case ENTER:
u->strdata = mallocstrcpy(NULL, openfile->current->data);
@@ -1509,11 +1498,7 @@ bool do_wrap(filestruct *line)
line_len = strlen(line->data);
/* Find the last blank where we can break the line. */
wrap_loc = break_line(line->data, fill
#ifndef DISABLE_HELP
, FALSE
#endif
);
wrap_loc = break_line(line->data, fill, FALSE);
/* If we couldn't break the line, or we've reached the end of it, we
* don't wrap. */
@@ -1622,98 +1607,72 @@ bool do_wrap(filestruct *line)
* that the display length to there is at most (goal + 1). If there is
* no such blank, then we find the first blank. We then take the last
* blank in that group of blanks. The terminating '\0' counts as a
* blank, as does a '\n' if newln is TRUE. */
ssize_t break_line(const char *line, ssize_t goal
#ifndef DISABLE_HELP
, bool newln
#endif
)
* blank, as does a '\n' if snap_at_nl is TRUE. */
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
{
ssize_t blank_loc = -1;
/* Current tentative return value. Index of the last blank we
* found with short enough display width. */
ssize_t cur_loc = 0;
/* Current index in line. */
size_t cur_pos = 0;
/* Current column position in line. */
ssize_t lastblank = -1;
/* The index of the last blank we found. */
ssize_t index = 0;
/* The index of the character we are looking at. */
size_t column = 0;
/* The column position that corresponds with index. */
int char_len = 0;
/* Length of current character, in bytes. */
/* The length of the current character, in bytes. */
assert(line != NULL);
/* Find the last blank that does not overshoot the target column. */
while (*line != '\0' && column <= goal) {
if (is_blank_mbchar(line) || (snap_at_nl && *line == '\n')) {
lastblank = index;
while (*line != '\0' && goal >= cur_pos) {
char_len = parse_mbchar(line, NULL, &cur_pos);
if (is_blank_mbchar(line)
#ifndef DISABLE_HELP
|| (newln && *line == '\n')
#endif
) {
blank_loc = cur_loc;
#ifndef DISABLE_HELP
if (newln && *line == '\n')
if (*line == '\n')
break;
#endif
}
char_len = parse_mbchar(line, NULL, &column);
line += char_len;
cur_loc += char_len;
index += char_len;
}
if (goal >= cur_pos)
/* In fact, the whole line displays shorter than goal. */
return cur_loc;
/* If the whole line displays shorter than goal, we're done. */
if (column <= goal)
return index;
#ifndef DISABLE_HELP
if (newln && blank_loc <= 0) {
/* If no blank was found, or was found only as the first
* character, force a line break. */
cur_loc -= char_len;
return cur_loc;
}
/* If we're wrapping a help text and no blank was found, or was
* found only as the first character, force a line break. */
if (snap_at_nl && lastblank < 1)
return (index - char_len);
#endif
if (blank_loc == -1) {
/* No blank was found within the goal width,
* so now try and find a blank beyond it. */
bool found_blank = FALSE;
ssize_t found_blank_loc = 0;
/* If no blank was found within the goal width, seek one after it. */
if (lastblank < 0) {
while (*line != '\0') {
if (is_blank_mbchar(line))
lastblank = index;
else if (lastblank > 0)
return lastblank;
char_len = parse_mbchar(line, NULL, NULL);
if (is_blank_mbchar(line)
#ifndef DISABLE_HELP
|| (newln && *line == '\n')
#endif
) {
found_blank = TRUE;
found_blank_loc = cur_loc;
} else if (found_blank)
return found_blank_loc;
line += char_len;
cur_loc += char_len;
index += char_len;
}
return -1;
}
/* Move to the last blank after blank_loc, if there is one. */
line -= cur_loc;
line += blank_loc;
/* Move the pointer back to the last blank, and then step beyond it. */
line = line - index + lastblank;
char_len = parse_mbchar(line, NULL, NULL);
line += char_len;
/* Skip any consecutive blanks after the last blank. */
while (*line != '\0' && is_blank_mbchar(line)) {
lastblank += char_len;
char_len = parse_mbchar(line, NULL, NULL);
line += char_len;
blank_loc += char_len;
}
return blank_loc;
return lastblank;
}
#endif /* !DISABLE_HELP || !DISABLE_WRAPJUSTIFY */
@@ -1903,13 +1862,9 @@ void justify_format(filestruct *paragraph, size_t skip)
/* The "quote part" of a line is the largest initial substring matching
* the quote string. This function returns the length of the quote part
* of the given line.
*
* Note that if !HAVE_REGEX_H then we match concatenated copies of
* quotestr. */
* of the given line. */
size_t quote_length(const char *line)
{
#ifdef HAVE_REGEX_H
regmatch_t matches;
int rc = regexec(&quotereg, line, 1, &matches, 0);
@@ -1918,14 +1873,6 @@ size_t quote_length(const char *line)
/* matches.rm_so should be 0, since the quote string should start
* with the caret ^. */
return matches.rm_eo;
#else /* !HAVE_REGEX_H */
size_t qdepth = 0;
/* Compute quote depth level. */
while (strncmp(line + qdepth, quotestr, quotelen) == 0)
qdepth += quotelen;
return qdepth;
#endif /* !HAVE_REGEX_H */
}
/* a_line and b_line are lines of text. The quotation part of a_line is
@@ -2127,12 +2074,10 @@ bool find_paragraph(size_t *const quote, size_t *const par)
filestruct *current_save;
/* The line at the beginning of the paragraph we search for. */
#ifdef HAVE_REGEX_H
if (quoterc != 0) {
statusline(ALERT, _("Bad quote string %s: %s"), quotestr, quoteerr);
return FALSE;
}
#endif
assert(openfile->current != NULL);
@@ -2215,9 +2160,9 @@ void do_justify(bool full_justify)
/* We save these variables to be restored if the user
* unjustifies. */
filestruct *edittop_save = openfile->edittop;
size_t firstcolumn_save = openfile->firstcolumn;
filestruct *current_save = openfile->current;
size_t current_x_save = openfile->current_x;
size_t totsize_save = openfile->totsize;
#ifndef NANO_TINY
filestruct *mark_begin_save = openfile->mark_begin;
size_t mark_begin_x_save = openfile->mark_begin_x;
@@ -2396,11 +2341,7 @@ void do_justify(bool full_justify)
/* If this line is too long, try to wrap it to the next line
* to make it short enough. */
break_pos = break_line(openfile->current->data + indent_len,
fill - strnlenpt(openfile->current->data, indent_len)
#ifndef DISABLE_HELP
, FALSE
#endif
);
fill - strnlenpt(openfile->current->data, indent_len), FALSE);
/* We can't break the line, or don't need to, so get out. */
if (break_pos == -1 || break_pos + indent_len == line_len)
@@ -2510,7 +2451,7 @@ void do_justify(bool full_justify)
/* If needed, unset the cursor-position suppression flag, so the cursor
* position /will/ be displayed upon a return to the main loop. */
if (ISSET(CONST_UPDATE))
do_cursorpos(TRUE);
do_cursorpos(FALSE);
func = func_from_key(&kbinput);
@@ -2522,29 +2463,20 @@ void do_justify(bool full_justify)
/* If we actually justified something, then splice the preserved
* unjustified text back into the file, */
if (first_par_line != NULL) {
/* Partition the filestruct so that it contains only the
* text of the justified paragraph. */
filepart = partition_filestruct(first_par_line, 0,
last_par_line, filebot_inpar ?
strlen(last_par_line->data) : 0);
filestruct *trash = NULL, *dummy = NULL;
/* Throw away the justified paragraph, and replace it with
* the preserved unjustified text. */
free_filestruct(openfile->fileage);
openfile->fileage = jusbuffer;
openfile->filebot = jusbottom;
extract_buffer(&trash, &dummy, first_par_line, 0, last_par_line,
filebot_inpar ? strlen(last_par_line->data) : 0);
free_filestruct(trash);
ingraft_buffer(jusbuffer);
/* Unpartition the filestruct, to contain the entire text again. */
unpartition_filestruct(&filepart);
/* Renumber, from the beginning of the unjustified part. */
renumber(jusbuffer);
/* Restore the old position, the size, and the mark. */
/* Restore the old position and the mark. */
openfile->edittop = edittop_save;
openfile->firstcolumn = firstcolumn_save;
openfile->current = current_save;
openfile->current_x = current_x_save;
openfile->totsize = totsize_save;
#ifndef NANO_TINY
if (openfile->mark_set) {
openfile->mark_begin = mark_begin_save;
@@ -2602,6 +2534,7 @@ void do_full_justify(void)
bool do_int_spell_fix(const char *word)
{
char *save_search, *exp_word;
size_t firstcolumn_save = openfile->firstcolumn;
size_t current_x_save = openfile->current_x;
filestruct *edittop_save = openfile->edittop;
filestruct *current_save = openfile->current;
@@ -2723,6 +2656,7 @@ bool do_int_spell_fix(const char *word)
/* Restore the viewport to where it was. */
openfile->edittop = edittop_save;
openfile->firstcolumn = firstcolumn_save;
/* Restore the settings of the global flags. */
memcpy(flags, stash, sizeof(flags));
@@ -2916,27 +2850,13 @@ const char *do_alt_speller(char *tempfile_name)
size_t current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant;
ssize_t lineno_save = openfile->current->lineno;
bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
struct stat spellfileinfo;
time_t timestamp;
pid_t pid_spell;
char *ptr;
static int arglen = 3;
static char **spellargs = NULL;
#ifndef NANO_TINY
bool old_mark_set = openfile->mark_set;
bool added_magicline = FALSE;
/* Whether we added a magicline after filebot. */
filestruct *top, *bot;
size_t top_x, bot_x, was_x, new_x;
bool right_side_up = FALSE;
ssize_t mb_lineno_save = 0;
/* We're going to close the current file, and open the output of
* the alternate spell command. The line that mark_begin points
* to will be freed, so we save the line number and restore it
* afterwards. */
size_t size_of_surrounding = 0;
/* The size of the text outside of a marked region. */
#endif
/* Get the timestamp and the size of the temporary file. */
stat(tempfile_name, &spellfileinfo);
@@ -2946,18 +2866,10 @@ const char *do_alt_speller(char *tempfile_name)
if (spellfileinfo.st_size == 0)
return NULL;
#ifndef NANO_TINY
if (old_mark_set) {
/* If the mark is on, save the number of the line it starts on,
* and then turn the mark off. */
mb_lineno_save = openfile->mark_begin->lineno;
openfile->mark_set = FALSE;
}
#endif
/* Exit from curses mode. */
endwin();
/* Set up an argument list to pass to execvp(). */
/* Set up the argument list to pass to execvp(). */
if (spellargs == NULL) {
spellargs = (char **)nmalloc(arglen * sizeof(char *));
@@ -2972,17 +2884,13 @@ const char *do_alt_speller(char *tempfile_name)
}
spellargs[arglen - 2] = tempfile_name;
/* Start a new process for the alternate speller. */
/* Fork a child process and run the alternate spell program in it. */
if ((pid_spell = fork()) == 0) {
/* Start alternate spell program; we are using $PATH. */
execvp(spellargs[0], spellargs);
/* Should not be reached, if alternate speller is found!!! */
/* Terminate the child process if no alternate speller is found. */
exit(1);
}
/* If we couldn't fork, get out. */
if (pid_spell < 0)
} else if (pid_spell < 0)
return _("Could not fork");
#ifndef NANO_TINY
@@ -2999,78 +2907,42 @@ const char *do_alt_speller(char *tempfile_name)
/* Restore the terminal to its previous state. */
terminal_init();
if (!WIFEXITED(alt_spell_status) || WEXITSTATUS(alt_spell_status) != 0) {
#ifndef NANO_TINY
/* Turn the mark back on if it was on before. */
openfile->mark_set = old_mark_set;
#endif
if (!WIFEXITED(alt_spell_status) || WEXITSTATUS(alt_spell_status) != 0)
return invocation_error(alt_speller);
}
#ifndef NANO_TINY
if (old_mark_set) {
/* Trim the filestruct so that it contains only the marked text. */
/* Replace the marked text (or the entire text) of the current buffer
* with the spell-checked text. */
if (openfile->mark_set) {
filestruct *top, *bot;
size_t top_x, bot_x;
bool right_side_up;
ssize_t was_mark_lineno = openfile->mark_begin->lineno;
openfile->mark_set = FALSE;
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
filepart = partition_filestruct(top, top_x, bot, bot_x);
/* Foresay whether a magicline will be added when the
* spell-checked text is read back in. */
if (!ISSET(NO_NEWLINES))
added_magicline = (openfile->filebot->data[0] != '\0');
/* Compute the size of the text outside of the marked region. */
size_of_surrounding = openfile->totsize - get_totsize(top, bot);
}
#endif
/* Replace the text of the current buffer with the spell-checked text. */
replace_buffer(tempfile_name);
#ifndef NANO_TINY
if (old_mark_set) {
filestruct *top_save = openfile->fileage;
/* If a magicline was added, remove it again. */
if (added_magicline)
remove_magicline();
replace_marked_buffer(tempfile_name, top, top_x, bot, bot_x);
/* Adjust the end point of the marked region for any change in
* length of the region's last line. */
if (right_side_up)
was_x = current_x_save;
current_x_save = openfile->current_x;
else
was_x = openfile->mark_begin_x;
if (top == bot)
new_x = was_x - bot_x + top_x + strlen(openfile->filebot->data);
else
new_x = strlen(openfile->filebot->data);
if (right_side_up)
current_x_save = new_x;
else
openfile->mark_begin_x = new_x;
openfile->mark_begin_x = openfile->current_x;
/* Unpartition the filestruct so that it contains all the text
* again. Note that we've replaced the marked text originally
* in the partition with the spell-checked marked text in the
* temp file. */
unpartition_filestruct(&filepart);
/* Renumber, starting with the beginning line of the old partition. */
renumber(top_save);
/* Add back the size of the text surrounding the marked region. */
openfile->totsize += size_of_surrounding;
/* Restore the position of the mark, and turn it back on. */
openfile->mark_begin = fsfromline(mb_lineno_save);
/* Restore the mark's position and turn it back on. */
openfile->mark_begin = fsfromline(was_mark_lineno);
openfile->mark_set = TRUE;
}
#endif /* !NANO_TINY */
} else
#endif
replace_buffer(tempfile_name);
/* Go back to the old position. */
goto_line_posx(lineno_save, current_x_save);
if (openfile->current_x > strlen(openfile->current->data))
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = pww_save;
adjust_viewport(STATIONARY);
@@ -3086,6 +2958,7 @@ const char *do_alt_speller(char *tempfile_name)
discard_until(NULL, openfile);
#endif
}
#ifndef NANO_TINY
/* Unblock SIGWINCHes again. */
allow_sigwinch(TRUE);
@@ -3472,6 +3345,7 @@ void do_formatter(void)
ssize_t lineno_save = openfile->current->lineno;
size_t current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant;
bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
pid_t pid_format;
static int arglen = 3;
static char **formatargs = NULL;
@@ -3549,7 +3423,7 @@ void do_formatter(void)
/* Restore the cursor position. */
goto_line_posx(lineno_save, current_x_save);
if (openfile->current_x > strlen(openfile->current->data))
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = pww_save;
adjust_viewport(STATIONARY);
@@ -3664,11 +3538,9 @@ void do_verbatim_input(void)
/* Read in all the verbatim characters. */
kbinput = get_verbatim_kbinput(edit, &kbinput_len);
/* If constant cursor position display is on, make sure the current
* cursor position will be properly displayed on the statusbar.
* Otherwise, blank the statusbar. */
/* Unsuppress cursor-position display or blank the statusbar. */
if (ISSET(CONST_UPDATE))
do_cursorpos(TRUE);
do_cursorpos(FALSE);
else {
blank_statusbar();
wnoutrefresh(bottomwin);

View File

@@ -25,7 +25,9 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#include <ctype.h>
#include <errno.h>
@@ -36,6 +38,7 @@ void get_homedir(void)
if (homedir == NULL) {
const char *homenv = getenv("HOME");
#ifdef HAVE_PWD_H
/* When HOME isn't set, or when we're root, get the home directory
* from the password file instead. */
if (homenv == NULL || geteuid() == 0) {
@@ -44,6 +47,7 @@ void get_homedir(void)
if (userage != NULL)
homenv = userage->pw_dir;
}
#endif
/* Only set homedir if some home directory could be determined,
* otherwise keep homedir NULL. */
@@ -170,94 +174,6 @@ void sunder(char *str)
}
}
/* These functions, ngetline() (originally getline()) and ngetdelim()
* (originally getdelim()), were adapted from GNU mailutils 0.5
* (mailbox/getline.c). Here is the notice from that file, after
* converting to the GPL via LGPL clause 3, and with the Free Software
* Foundation's address and the copyright years updated:
*
* GNU Mailutils -- a suite of utilities for electronic mail
* Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007
* Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301, USA. */
#ifndef DISABLE_NANORC
#ifndef HAVE_GETDELIM
/* This function is equivalent to getdelim(). */
ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream)
{
size_t indx = 0;
int c;
/* Sanity checks. */
if (lineptr == NULL || n == NULL || stream == NULL ||
fileno(stream) == -1) {
errno = EINVAL;
return -1;
}
/* Allocate the line the first time. */
if (*lineptr == NULL) {
*n = MAX_BUF_SIZE;
*lineptr = charalloc(*n);
}
while ((c = getc(stream)) != EOF) {
/* Check if more memory is needed. */
if (indx >= *n) {
*n += MAX_BUF_SIZE;
*lineptr = charealloc(*lineptr, *n);
}
/* Put the result in the line. */
(*lineptr)[indx++] = (char)c;
/* Bail out. */
if (c == delim)
break;
}
/* Make room for the null character. */
if (indx >= *n) {
*n += MAX_BUF_SIZE;
*lineptr = charealloc(*lineptr, *n);
}
/* Null-terminate the buffer. */
null_at(lineptr, indx++);
*n = indx;
/* The last line may not have the delimiter. We have to return what
* we got, and the error will be seen on the next iteration. */
return (c == EOF && (indx - 1) == 0) ? -1 : indx - 1;
}
#endif
#ifndef HAVE_GETLINE
/* This function is equivalent to getline(). */
ssize_t ngetline(char **lineptr, size_t *n, FILE *stream)
{
return getdelim(lineptr, n, '\n', stream);
}
#endif
#endif /* !DISABLE_NANORC */
#ifdef HAVE_REGEX_H
/* Fix the regex if we're on platforms which require an adjustment
* from GNU-style to BSD-style word boundaries. */
const char *fixbounds(const char *r)
@@ -293,7 +209,6 @@ const char *fixbounds(const char *r)
return r;
}
#endif /* HAVE_REGEX_H */
#ifndef DISABLE_SPELLER
/* Is the word starting at the given position in buf and of the given length
@@ -323,7 +238,6 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
const char *strstrwrapper(const char *haystack, const char *needle,
const char *start)
{
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) {
if (ISSET(BACKWARDS_SEARCH)) {
size_t last_find, ceiling, far_end;
@@ -376,7 +290,6 @@ const char *strstrwrapper(const char *haystack, const char *needle,
else
return haystack + regmatches[0].rm_so;
}
#endif /* HAVE_REGEX_H */
if (ISSET(CASE_SENSITIVE)) {
if (ISSET(BACKWARDS_SEARCH))
return revstrstr(haystack, needle, start);
@@ -454,13 +367,14 @@ char *free_and_assign(char *dest, char *src)
return src;
}
/* nano scrolls horizontally within a line in chunks. Return the column
* number of the first character displayed in the edit window when the
/* When not in softwrap mode, nano scrolls horizontally within a line in
* chunks (a bit smaller than the chunks used in softwrapping). Return the
* column number of the first character displayed in the edit window when the
* cursor is at the given column. Note that (0 <= column -
* get_page_start(column) < COLS). */
size_t get_page_start(size_t column)
{
if (column == 0 || column < editwincols - 1)
if (column < editwincols - 1 || ISSET(SOFTWRAP) || column == 0)
return 0;
else if (editwincols > 8)
return column - 7 - (column - 7) % (editwincols - 8);
@@ -520,11 +434,15 @@ size_t strnlenpt(const char *text, size_t maxlen)
return width;
}
/* A strlen() with tabs and multicolumn characters factored in:
* how many columns wide is text? */
/* Return the number of columns that the given text occupies. */
size_t strlenpt(const char *text)
{
return strnlenpt(text, (size_t)-1);
size_t span = 0;
while (*text != '\0')
text += parse_mbchar(text, NULL, &span);
return span;
}
/* Append a new magicline to filebot. */

View File

@@ -1486,40 +1486,39 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
}
#endif
*count = 1;
#ifdef ENABLE_UTF8
if (using_utf8()) {
/* Check whether the first code is a valid starter digit: 0 or 1. */
long uni = get_unicode_kbinput(win, *kbinput);
long unicode = get_unicode_kbinput(win, *kbinput);
/* If the first code isn't the digit 0 nor 1, put it back. */
if (uni != ERR)
if (unicode != ERR)
unget_input(kbinput, 1);
/* Otherwise, continue reading in digits until we have a complete
* Unicode value, and put back the corresponding byte(s). */
else {
char *uni_mb;
int uni_mb_len, *seq, i;
char *multibyte;
int onebyte, i;
while (uni == ERR) {
while (unicode == ERR) {
free(kbinput);
while ((kbinput = get_input(win, 1)) == NULL)
;
uni = get_unicode_kbinput(win, *kbinput);
unicode = get_unicode_kbinput(win, *kbinput);
}
/* Convert the Unicode value to a multibyte sequence. */
uni_mb = make_mbchar(uni, &uni_mb_len);
seq = (int *)nmalloc(uni_mb_len * sizeof(int));
for (i = 0; i < uni_mb_len; i++)
seq[i] = (unsigned char)uni_mb[i];
multibyte = make_mbchar(unicode, (int *)count);
/* Insert the multibyte sequence into the input buffer. */
unget_input(seq, uni_mb_len);
for (i = *count; i > 0 ; i--) {
onebyte = (unsigned char)multibyte[i - 1];
unget_input(&onebyte, 1);
}
free(seq);
free(uni_mb);
free(multibyte);
}
} else
#endif /* ENABLE_UTF8 */
@@ -1528,8 +1527,6 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
free(kbinput);
*count = 1;
/* If this is an iTerm/Eterm/rxvt double escape, take both Escapes. */
if (key_buffer_len > 3 && *key_buffer == ESC_CODE &&
key_buffer[1] == ESC_CODE && key_buffer[2] == '[')
@@ -1810,28 +1807,23 @@ char *display_string(const char *buf, size_t start_col, size_t span,
/* The string we return. */
size_t index;
/* Current position in converted. */
/* If this is data, make room for the "$" at the end of the line. */
if (isdata && !ISSET(SOFTWRAP) && strlenpt(buf) > start_col + span)
span--;
if (span == 0)
return mallocstrcpy(NULL, "");
size_t beyond = start_col + span;
/* The column number just beyond the last shown character. */
start_index = actual_x(buf, start_col);
column = strnlenpt(buf, start_index);
assert(column <= start_col);
/* Allocate enough space to hold the entire converted buffer. */
converted = charalloc(strlen(buf) * (mb_cur_max() + tabsize) + 1);
index = 0;
#ifdef USING_OLD_NCURSES
seen_wide = FALSE;
#endif
buf += start_index;
/* Allocate enough space for converting the relevant part of the line. */
converted = charalloc(strlen(buf) * (mb_cur_max() + tabsize) + 1);
/* If the first character starts before the left edge, or would be
* overwritten by a "$" token, then show spaces instead. */
if (*buf != '\0' && *buf != '\t' && (column < start_col ||
@@ -1858,7 +1850,7 @@ char *display_string(const char *buf, size_t start_col, size_t span,
#endif
}
while (*buf != '\0') {
while (*buf != '\0' && start_col < beyond) {
int charlength, charwidth = 1;
if (*buf == ' ') {
@@ -1933,12 +1925,12 @@ char *display_string(const char *buf, size_t start_col, size_t span,
buf += charlength + 7;
}
/* Null-terminate converted. */
converted[index] = '\0';
/* If there is more text than can be shown, make room for the $. */
if (*buf != '\0' && isdata && !ISSET(SOFTWRAP))
index = move_mbleft(converted, index);
/* Make sure converted takes up no more than span columns. */
index = actual_x(converted, span);
null_at(&converted, index);
/* Null-terminate the converted string. */
converted[index] = '\0';
return converted;
}
@@ -2119,12 +2111,12 @@ void statusline(message_type importance, const char *msg, ...)
/* Shortly pause after each of the first three alert messages,
* to give the user time to read them. */
if (lastmessage == ALERT && alerts < 4)
if (lastmessage == ALERT && alerts < 4 && !ISSET(NO_PAUSES))
napms(1200);
if (importance == ALERT) {
if (++alerts > 3)
msg = "Some warnings were suppressed";
if (++alerts > 3 && !ISSET(NO_PAUSES))
msg = _("Further warnings were suppressed");
beep();
}
@@ -2266,33 +2258,38 @@ void onekey(const char *keystroke, const char *desc, int length)
}
/* Redetermine current_y from the position of current relative to edittop,
* and put the cursor in the edit window at (current_y, current_x). */
* and put the cursor in the edit window at (current_y, "current_x"). */
void reset_cursor(void)
{
size_t xpt = xplustabs();
ssize_t row = 0;
size_t col, xpt = xplustabs();
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
filestruct *line = openfile->edittop;
openfile->current_y = 0;
row -= (openfile->firstcolumn / editwincols);
/* Calculate how many rows the lines from edittop to current use. */
while (line != NULL && line != openfile->current) {
openfile->current_y += strlenpt(line->data) / editwincols + 1;
row += strlenpt(line->data) / editwincols + 1;
line = line->next;
}
openfile->current_y += xpt / editwincols;
if (openfile->current_y < editwinrows)
wmove(edit, openfile->current_y, xpt % editwincols + margin);
/* Add the number of wraps in the current line before the cursor. */
row += xpt / editwincols;
col = xpt % editwincols;
} else
#endif
{
openfile->current_y = openfile->current->lineno -
openfile->edittop->lineno;
if (openfile->current_y < editwinrows)
wmove(edit, openfile->current_y, xpt - get_page_start(xpt) + margin);
row = openfile->current->lineno - openfile->edittop->lineno;
col = xpt - get_page_start(xpt);
}
if (row < editwinrows)
wmove(edit, row, margin + col);
openfile->current_y = row;
}
/* edit_draw() takes care of the job of actually painting a line into
@@ -2627,6 +2624,9 @@ void edit_draw(filestruct *fileptr, const char *converted,
/* Compute on which screen column to start painting. */
start_col = strnlenpt(fileptr->data, top_x) - from_col;
if (start_col < 0)
start_col = 0;
thetext = converted + actual_x(converted, start_col);
/* If the end of the mark is onscreen, compute how many
@@ -2647,8 +2647,9 @@ void edit_draw(filestruct *fileptr, const char *converted,
/* Redraw the line at fileptr. The line will be displayed so that the
* character with the given index is visible -- if necessary, the line
* will be horizontally scrolled. In softwrap mode, however, the entire
* line will be displayed. Likely values of index are current_x or zero.
* Return the number of additional rows consumed (when softwrapping). */
* line will be passed to update_softwrapped_line(). Likely values of
* index are current_x or zero. Return the number of additional rows
* consumed (when softwrapping). */
int update_line(filestruct *fileptr, size_t index)
{
int row = 0;
@@ -2659,44 +2660,18 @@ int update_line(filestruct *fileptr, size_t index)
/* From which column a horizontally scrolled line is displayed. */
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
filestruct *line = openfile->edittop;
/* Find out on which screen row the target line should be shown. */
while (line != fileptr && line != NULL) {
row += (strlenpt(line->data) / editwincols) + 1;
line = line->next;
}
} else
if (ISSET(SOFTWRAP))
return update_softwrapped_line(fileptr);
#endif
row = fileptr->lineno - openfile->edittop->lineno;
row = fileptr->lineno - openfile->edittop->lineno;
/* If the line is offscreen, don't even try to display it. */
if (row < 0 || row >= editwinrows)
if (row < 0 || row >= editwinrows) {
statusline(ALERT, "Badness: tried to display a line on row %i"
" -- please report a bug", row);
return 0;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
size_t full_length = strlenpt(fileptr->data);
int starting_row = row;
for (from_col = 0; from_col <= full_length &&
row < editwinrows; from_col += editwincols) {
/* First, blank out the row. */
blank_row(edit, row, 0, COLS);
/* Expand the line, replacing tabs with spaces, and control
* characters with their displayed forms. */
converted = display_string(fileptr->data, from_col, editwincols, TRUE);
/* Draw the line. */
edit_draw(fileptr, converted, row++, from_col);
free(converted);
}
return (row - starting_row);
}
#endif
/* First, blank out the row. */
blank_row(edit, row, 0, COLS);
@@ -2720,9 +2695,65 @@ int update_line(filestruct *fileptr, size_t index)
return 1;
}
/* Check whether old_column and new_column are on different "pages" (or that
* the mark is on), which means that the relevant line needs to be redrawn. */
bool need_horizontal_scroll(const size_t old_column, const size_t new_column)
#ifndef NANO_TINY
/* Redraw all the chunks of the given line (as far as they fit onscreen),
* unless it's edittop, which will be displayed from column firstcolumn.
* Return the number of additional rows consumed. */
int update_softwrapped_line(filestruct *fileptr)
{
int row = 0;
/* The row in the edit window we will write to. */
filestruct *line = openfile->edittop;
/* An iterator needed to find the relevant row. */
int starting_row;
/* The first row in the edit window that gets updated. */
size_t from_col = 0;
/* The starting column of the current chunk. */
char *converted;
/* The data of the chunk with tabs and control characters expanded. */
size_t full_length;
/* The length of the expanded line. */
if (fileptr == openfile->edittop)
from_col = openfile->firstcolumn;
else
row -= (openfile->firstcolumn / editwincols);
/* Find out on which screen row the target line should be shown. */
while (line != fileptr && line != NULL) {
row += (strlenpt(line->data) / editwincols) + 1;
line = line->next;
}
/* If the first chunk is offscreen, don't even try to display it. */
if (row < 0 || row >= editwinrows) {
statusline(ALERT, "Badness: tried to display a chunk on row %i"
" -- please report a bug", row);
return 0;
}
full_length = strlenpt(fileptr->data);
starting_row = row;
while (from_col <= full_length && row < editwinrows) {
blank_row(edit, row, 0, COLS);
/* Convert the chunk to its displayable form and draw it. */
converted = display_string(fileptr->data, from_col, editwincols, TRUE);
edit_draw(fileptr, converted, row++, from_col);
free(converted);
from_col += editwincols;
}
return (row - starting_row);
}
#endif
/* Check whether the mark is on, or whether old_column and new_column are on
* different "pages" (in softwrap mode, only the former applies), which means
* that the relevant line needs to be redrawn. */
bool line_needs_update(const size_t old_column, const size_t new_column)
{
#ifndef NANO_TINY
if (openfile->mark_set)
@@ -2732,79 +2763,132 @@ bool need_horizontal_scroll(const size_t old_column, const size_t new_column)
return (get_page_start(old_column) != get_page_start(new_column));
}
/* Determine how many file lines we can display, accounting for softwraps. */
void compute_maxlines(void)
/* Try to move up nrows softwrapped chunks from the given line and the
* given column (leftedge). After moving, leftedge will be set to the
* starting column of the current chunk. Return the number of chunks we
* couldn't move up, which will be zero if we completely succeeded. */
int go_back_chunks(int nrows, filestruct **line, size_t *leftedge)
{
int i;
/* Don't move more chunks than the window can hold. */
if (nrows > editwinrows - 1)
nrows = (editwinrows < 2) ? 1 : editwinrows - 1;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
size_t current_chunk = (*leftedge) / editwincols;
/* Recede through the requested number of chunks. */
for (i = nrows; i > 0; i--) {
if (current_chunk > 0) {
current_chunk--;
continue;
}
if (*line == openfile->fileage)
break;
*line = (*line)->prev;
current_chunk = strlenpt((*line)->data) / editwincols;
}
/* Only change leftedge when we actually could move. */
if (i < nrows)
*leftedge = current_chunk * editwincols;
} else
#endif
for (i = nrows; i > 0 && (*line)->prev != NULL; i--)
*line = (*line)->prev;
return i;
}
/* Try to move down nrows softwrapped chunks from the given line and the
* given column (leftedge). After moving, leftedge will be set to the
* starting column of the current chunk. Return the number of chunks we
* couldn't move down, which will be zero if we completely succeeded. */
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge)
{
int i;
/* Don't move more chunks than the window can hold. */
if (nrows > editwinrows - 1)
nrows = (editwinrows < 2) ? 1 : editwinrows - 1;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
size_t current_chunk = (*leftedge) / editwincols;
size_t last_chunk = strlenpt((*line)->data) / editwincols;
/* Advance through the requested number of chunks. */
for (i = nrows; i > 0; i--) {
if (current_chunk < last_chunk) {
current_chunk++;
continue;
}
if (*line == openfile->filebot)
break;
*line = (*line)->next;
current_chunk = 0;
last_chunk = strlenpt((*line)->data) / editwincols;
}
/* Only change leftedge when we actually could move. */
if (i < nrows)
*leftedge = current_chunk * editwincols;
} else
#endif
for (i = nrows; i > 0 && (*line)->next != NULL; i--)
*line = (*line)->next;
return i;
}
/* Return TRUE if there are fewer than a screen's worth of lines between
* the line at line number was_lineno (and column was_leftedge, if we're
* in softwrap mode) and the line at current[current_x]. */
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge)
{
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
filestruct *line = openfile->edittop;
int row = 0;
filestruct *line = openfile->current;
size_t leftedge = (xplustabs() / editwincols) * editwincols;
int rows_left = go_back_chunks(editwinrows - 1, &line, &leftedge);
maxlines = 0;
while (row < editwinrows && line != NULL) {
row += (strlenpt(line->data) / editwincols) + 1;
line = line->next;
maxlines++;
}
if (row < editwinrows)
maxlines += (editwinrows - row);
#ifdef DEBUG
fprintf(stderr, "recomputed: maxlines = %d\n", maxlines);
#endif
return (rows_left > 0 || line->lineno < was_lineno ||
(line->lineno == was_lineno && leftedge <= was_leftedge));
} else
#endif /* !NANO_TINY */
maxlines = editwinrows;
#endif
return (openfile->current->lineno - was_lineno < editwinrows);
}
/* Scroll the edit window in the given direction and the given number of rows,
* and draw new lines on the blank lines left after the scrolling. We change
* edittop, and assume that current and current_x are up to date. */
* and draw new lines on the blank lines left after the scrolling. */
void edit_scroll(scroll_dir direction, int nrows)
{
int i;
filestruct *line;
size_t leftedge;
/* Part 1: nrows is the number of rows we're going to scroll the text of
* the edit window. */
/* Move the top line of the edit window up or down (depending on the value
* of direction) nrows rows, or as many rows as we can if there are fewer
* than nrows rows available. */
for (i = nrows; i > 0; i--) {
if (direction == UPWARD) {
if (openfile->edittop == openfile->fileage)
break;
openfile->edittop = openfile->edittop->prev;
} else {
if (openfile->edittop == openfile->filebot)
break;
openfile->edittop = openfile->edittop->next;
}
#ifndef NANO_TINY
/* Don't over-scroll on long lines. */
if (ISSET(SOFTWRAP) && direction == UPWARD) {
ssize_t len = strlenpt(openfile->edittop->data) / editwincols;
i -= len;
if (len > 0)
refresh_needed = TRUE;
}
#endif
}
/* Limit nrows to the number of rows we could scroll. */
nrows -= i;
/* Move the top line of the edit window the requested number of rows up or
* down, and reduce the number of rows with the amount we couldn't move. */
if (direction == UPWARD)
nrows -= go_back_chunks(nrows, &openfile->edittop, &openfile->firstcolumn);
else
nrows -= go_forward_chunks(nrows, &openfile->edittop, &openfile->firstcolumn);
/* Don't bother scrolling zero rows, nor more than the window can hold. */
if (nrows == 0)
return;
if (nrows >= editwinrows)
if (nrows >= editwinrows) {
refresh_needed = TRUE;
if (refresh_needed == TRUE)
return;
}
/* Scroll the text of the edit window a number of rows up or down. */
scrollok(edit, TRUE);
@@ -2814,41 +2898,88 @@ void edit_scroll(scroll_dir direction, int nrows)
/* Part 2: nrows is now the number of rows in the scrolled region of the
* edit window that we need to draw. */
/* If the scrolled region contains only one row, and the row before it is
* visible in the edit window, we need to draw it too. If the scrolled
* region is more than one row, and the rows before and after it are
* visible in the edit window, we need to draw them too. */
nrows += (nrows == 1) ? 1 : 2;
/* If we're not on the first "page" (when not softwrapping), or the mark
* is on, the row next to the scrolled region needs to be redrawn too. */
if (line_needs_update(openfile->placewewant, 0) && nrows < editwinrows)
nrows++;
if (nrows > editwinrows)
nrows = editwinrows;
/* If we scrolled up, we're on the line before the scrolled region. */
/* If we scrolled backward, start on the first line of the blank region. */
line = openfile->edittop;
leftedge = openfile->firstcolumn;
/* If we scrolled down, move down to the line before the scrolled region. */
if (direction == DOWNWARD) {
for (i = editwinrows - nrows; i > 0 && line != NULL; i--)
line = line->next;
}
/* If we scrolled forward, move down to the start of the blank region. */
if (direction == DOWNWARD)
go_forward_chunks(editwinrows - nrows, &line, &leftedge);
/* Draw new lines on any blank rows before or inside the scrolled region.
* If we scrolled down and we're on the top row, or if we scrolled up and
* we're on the bottom row, the row won't be blank, so we don't need to
* draw it unless the mark is on or we're not on the first "page". */
for (i = nrows; i > 0 && line != NULL; i--) {
if ((i == nrows && direction == DOWNWARD) ||
(i == 1 && direction == UPWARD)) {
if (need_horizontal_scroll(openfile->placewewant, 0))
update_line(line, (line == openfile->current) ?
openfile->current_x : 0);
} else
update_line(line, (line == openfile->current) ?
openfile->current_x : 0);
#ifndef NANO_TINY
/* Compensate for the earlier onscreen chunks of a softwrapped line
* when the first blank row happens to be in the middle of that line. */
if (ISSET(SOFTWRAP) && line != openfile->edittop)
nrows += leftedge / editwincols;
#endif
/* Draw new content on the blank rows inside the scrolled region
* (and on the bordering row too when it was deemed necessary). */
while (nrows > 0 && line != NULL) {
nrows -= update_line(line, (line == openfile->current) ?
openfile->current_x : 0);
line = line->next;
}
}
compute_maxlines();
/* Ensure that firstcolumn is at the starting column of the softwrapped chunk
* it's on. We need to do this when the number of columns of the edit window
* has changed, because then the width of softwrapped chunks has changed. */
void ensure_firstcolumn_is_aligned(void)
{
#ifndef NANO_TINY
if (openfile->firstcolumn % editwincols != 0)
openfile->firstcolumn -= (openfile->firstcolumn % editwincols);
#endif
}
/* Return TRUE if current[current_x] is above the top of the screen, and FALSE
* otherwise. */
bool current_is_above_screen(void)
{
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
/* The cursor is above screen when current[current_x] is before edittop
* at column firstcolumn. */
return (openfile->current->lineno < openfile->edittop->lineno ||
(openfile->current->lineno == openfile->edittop->lineno &&
xplustabs() < openfile->firstcolumn));
else
#endif
return (openfile->current->lineno < openfile->edittop->lineno);
}
/* Return TRUE if current[current_x] is below the bottom of the screen, and
* FALSE otherwise. */
bool current_is_below_screen(void)
{
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
filestruct *line = openfile->edittop;
size_t leftedge = openfile->firstcolumn;
/* If current[current_x] is more than a screen's worth of lines after
* edittop at column firstcolumn, it's below the screen. */
return (go_forward_chunks(editwinrows - 1, &line, &leftedge) == 0 &&
(line->lineno < openfile->current->lineno ||
(line->lineno == openfile->current->lineno &&
leftedge < (xplustabs() / editwincols) * editwincols)));
} else
#endif
return (openfile->current->lineno >=
openfile->edittop->lineno + editwinrows);
}
/* Return TRUE if current[current_x] is offscreen relative to edittop, and
* FALSE otherwise. */
bool current_is_offscreen(void)
{
return (current_is_above_screen() || current_is_below_screen());
}
/* Update any lines between old_current and current that need to be
@@ -2860,12 +2991,7 @@ void edit_redraw(filestruct *old_current)
openfile->placewewant = xplustabs();
/* If the current line is offscreen, scroll until it's onscreen. */
if (openfile->current->lineno >= openfile->edittop->lineno + maxlines ||
#ifndef NANO_TINY
(openfile->current->lineno == openfile->edittop->lineno + maxlines - 1 &&
ISSET(SOFTWRAP) && strlenpt(openfile->current->data) >= editwincols) ||
#endif
openfile->current->lineno < openfile->edittop->lineno) {
if (current_is_offscreen()) {
adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : FLOWING);
refresh_needed = TRUE;
return;
@@ -2891,7 +3017,7 @@ void edit_redraw(filestruct *old_current)
/* Update current if the mark is on or it has changed "page", or if it
* differs from old_current and needs to be horizontally scrolled. */
if (need_horizontal_scroll(was_pww, openfile->placewewant) ||
if (line_needs_update(was_pww, openfile->placewewant) ||
(old_current != openfile->current &&
get_page_start(openfile->placewewant) > 0))
update_line(openfile->current, openfile->current_x);
@@ -2904,15 +3030,11 @@ void edit_refresh(void)
filestruct *line;
int row = 0;
/* Figure out what maxlines should really be. */
compute_maxlines();
/* If the current line is out of view, get it back on screen. */
if (openfile->current->lineno < openfile->edittop->lineno ||
openfile->current->lineno >= openfile->edittop->lineno + maxlines) {
if (current_is_offscreen()) {
#ifdef DEBUG
fprintf(stderr, "edit-refresh: line = %ld, edittop = %ld and maxlines = %d\n",
(long)openfile->current->lineno, (long)openfile->edittop->lineno, maxlines);
fprintf(stderr, "edit-refresh: line = %ld, edittop = %ld and editwinrows = %d\n",
(long)openfile->current->lineno, (long)openfile->edittop->lineno, editwinrows);
#endif
adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : STATIONARY);
}
@@ -2960,13 +3082,8 @@ void adjust_viewport(update_type manner)
if (manner == CENTERING)
goal = editwinrows / 2;
else if (manner == FLOWING) {
if (openfile->current->lineno >= openfile->edittop->lineno) {
if (!current_is_above_screen())
goal = editwinrows - 1;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
goal -= strlenpt(openfile->current->data) / editwincols;
#endif
}
} else {
goal = openfile->current_y;
@@ -2977,21 +3094,17 @@ void adjust_viewport(update_type manner)
openfile->edittop = openfile->current;
while (goal > 0 && openfile->edittop->prev != NULL) {
openfile->edittop = openfile->edittop->prev;
goal--;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
goal -= strlenpt(openfile->edittop->data) / editwincols;
if (goal < 0)
openfile->edittop = openfile->edittop->next;
}
if (ISSET(SOFTWRAP))
openfile->firstcolumn = (xplustabs() / editwincols) * editwincols;
#endif
}
/* Move edittop back goal rows, starting at current[current_x]. */
go_back_chunks(goal, &openfile->edittop, &openfile->firstcolumn);
#ifdef DEBUG
fprintf(stderr, "adjust_viewport(): setting edittop to lineno %ld\n", (long)openfile->edittop->lineno);
#endif
compute_maxlines();
}
/* Unconditionally redraw the entire screen. */
@@ -3032,10 +3145,10 @@ void display_main_list(void)
bottombars(MMAIN);
}
/* If constant is TRUE, we display the current cursor position only if
* suppress_cursorpos is FALSE. If constant is FALSE, we display the
* position always. In any case we reset suppress_cursorpos to FALSE. */
void do_cursorpos(bool constant)
/* Show info about the current cursor position on the statusbar.
* Do this unconditionally when force is TRUE; otherwise, only if
* suppress_cursorpos is FALSE. In any case, reset the latter. */
void do_cursorpos(bool force)
{
char saved_byte;
size_t sum, cur_xpt = xplustabs() + 1;
@@ -3056,8 +3169,8 @@ void do_cursorpos(bool constant)
if (openfile->current != openfile->filebot)
sum--;
/* If the position needs to be suppressed, don't suppress it next time. */
if (suppress_cursorpos && constant) {
/* If the showing needs to be suppressed, don't suppress it next time. */
if (suppress_cursorpos && !force) {
suppress_cursorpos = FALSE;
return;
}
@@ -3081,7 +3194,7 @@ void do_cursorpos(bool constant)
/* Unconditionally display the current cursor position. */
void do_cursorpos_void(void)
{
do_cursorpos(FALSE);
do_cursorpos(TRUE);
}
void enable_nodelay(void)
@@ -3100,15 +3213,17 @@ void disable_nodelay(void)
* expect word to have tabs and control characters expanded. */
void spotlight(bool active, const char *word)
{
size_t word_len = strlenpt(word), room;
size_t word_span = strlenpt(word);
size_t room = word_span;
/* Compute the number of columns that are available for the word. */
room = editwincols + get_page_start(xplustabs()) - xplustabs();
if (!ISSET(SOFTWRAP)) {
room = editwincols + get_page_start(xplustabs()) - xplustabs();
assert(room > 0);
if (word_len > room)
room--;
/* If the word is partially offscreen, reserve space for the "$". */
if (word_span > room)
room--;
}
reset_cursor();
@@ -3116,12 +3231,12 @@ void spotlight(bool active, const char *word)
wattron(edit, hilite_attribute);
/* This is so we can show zero-length matches. */
if (word_len == 0)
if (word_span == 0)
waddch(edit, ' ');
else
waddnstr(edit, word, actual_x(word, room));
if (word_len > room)
if (word_span > room)
waddch(edit, '$');
if (active)

View File

@@ -7,7 +7,7 @@ comment "#"
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|comment|magic|linter|i?color|extendsyntax).*$"
# Keywords
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cut|fill[[:space:]]+[[:digit:]]+|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[[:digit:]]+|tabstospaces|tempfile|unix|view|wordbounds)\>"
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cut|fill[[:space:]]+[[:digit:]]+|historylog|justifytrim|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[[:digit:]]+|tabstospaces|tempfile|unix|view|wordbounds)\>"
icolor yellow "^[[:space:]]*set[[:space:]]+((function|key|number|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" "[[:space:]]+[[:digit:]]+$"
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+"
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"